summaryrefslogtreecommitdiffstats
path: root/modules/base/tool.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/base/tool.go')
-rw-r--r--modules/base/tool.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index d99ed2bab4..3a6e28a885 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -9,6 +9,7 @@ import (
"crypto/md5"
"crypto/rand"
"crypto/sha1"
+ "crypto/sha256"
"encoding/base64"
"encoding/hex"
"fmt"
@@ -54,6 +55,13 @@ func EncodeSha1(str string) string {
return hex.EncodeToString(h.Sum(nil))
}
+// EncodeSha256 string to sha1 hex value.
+func EncodeSha256(str string) string {
+ h := sha256.New()
+ h.Write([]byte(str))
+ return hex.EncodeToString(h.Sum(nil))
+}
+
// ShortSha is basically just truncating.
// It is DEPRECATED and will be removed in the future.
func ShortSha(sha1 string) string {