refactor: change hash function

This commit is contained in:
Andy Hsu
2023-07-15 16:28:55 +08:00
parent 9d1f122717
commit a4511c1963
11 changed files with 25 additions and 21 deletions

View File

@ -9,24 +9,28 @@ import (
"strings"
)
func GetSHA1Encode(data string) string {
func GetSHA1Encode(data []byte) string {
h := sha1.New()
h.Write([]byte(data))
h.Write(data)
return hex.EncodeToString(h.Sum(nil))
}
func GetSHA256Encode(data string) string {
func GetSHA256Encode(data []byte) string {
h := sha256.New()
h.Write([]byte(data))
h.Write(data)
return hex.EncodeToString(h.Sum(nil))
}
func GetMD5Encode(data string) string {
func GetMD5Encode(data []byte) string {
h := md5.New()
h.Write([]byte(data))
h.Write(data)
return hex.EncodeToString(h.Sum(nil))
}
func GetMD5EncodeStr(data string) string {
return GetMD5Encode([]byte(data))
}
var DEC = map[string]string{
"-": "+",
"_": "/",