summaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-07-31 17:25:34 -0400
committerUnknwon <joe2010xtmf@163.com>2014-07-31 17:25:34 -0400
commit7bbf644dd5eaca77c3e8df57419180486bda0fc2 (patch)
tree84033fb9507c4657d74b85dccd5f16595f8517a8 /modules/base
parent3428baa3b57b39f2e010254bffede93e7d3cdf37 (diff)
downloadgitea-7bbf644dd5eaca77c3e8df57419180486bda0fc2.tar.gz
gitea-7bbf644dd5eaca77c3e8df57419180486bda0fc2.zip
Convert captcha, cache, csrf as middlewares
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/template.go1
-rw-r--r--modules/base/tool.go28
2 files changed, 0 insertions, 29 deletions
diff --git a/modules/base/template.go b/modules/base/template.go
index b9968bae65..51b1dfff01 100644
--- a/modules/base/template.go
+++ b/modules/base/template.go
@@ -103,7 +103,6 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
"ActionContent2Commits": ActionContent2Commits,
"Oauth2Icon": Oauth2Icon,
"Oauth2Name": Oauth2Name,
- "CreateCaptcha": func() string { return "" },
}
type Actioner interface {
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 830c37f697..a2a155d61f 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -13,7 +13,6 @@ import (
"fmt"
"hash"
"math"
- r "math/rand"
"strings"
"time"
@@ -45,33 +44,6 @@ func GetRandomString(n int, alphabets ...byte) string {
return string(bytes)
}
-// RandomCreateBytes generate random []byte by specify chars.
-func RandomCreateBytes(n int, alphabets ...byte) []byte {
- const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- var bytes = make([]byte, n)
- var randby bool
- if num, err := rand.Read(bytes); num != n || err != nil {
- r.Seed(time.Now().UnixNano())
- randby = true
- }
- for i, b := range bytes {
- if len(alphabets) == 0 {
- if randby {
- bytes[i] = alphanum[r.Intn(len(alphanum))]
- } else {
- bytes[i] = alphanum[b%byte(len(alphanum))]
- }
- } else {
- if randby {
- bytes[i] = alphabets[r.Intn(len(alphabets))]
- } else {
- bytes[i] = alphabets[b%byte(len(alphabets))]
- }
- }
- }
- return bytes
-}
-
// http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto
func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte {
prf := hmac.New(h, password)