From 8c9338a5377c60c84cdee1f5781b3de5933bb3b0 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 12 Nov 2014 06:48:50 -0500 Subject: add personal access token panel #12 --- modules/base/tool.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules/base') diff --git a/modules/base/tool.go b/modules/base/tool.go index 4d3e1c7b..50f073a5 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -33,6 +33,13 @@ func EncodeMd5(str string) string { return hex.EncodeToString(m.Sum(nil)) } +// Encode string to sha1 hex value. +func EncodeSha1(str string) string { + h := sha1.New() + h.Write([]byte(str)) + return hex.EncodeToString(h.Sum(nil)) +} + func BasicAuthDecode(encoded string) (user string, name string, err error) { var s []byte s, err = base64.StdEncoding.DecodeString(encoded) -- cgit v1.2.3