main
lizifeng 2023-05-17 14:02:34 +08:00
parent 110c5088cc
commit 49b5ec8cd8
1 changed files with 7 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package mycrypto
import ( import (
"crypto/md5" "crypto/md5"
"crypto/sha1" "crypto/sha1"
"crypto/sha256"
"encoding/hex" "encoding/hex"
) )
@ -18,3 +19,9 @@ func Sha1(str string) string {
h.Write([]byte(str)) h.Write([]byte(str))
return hex.EncodeToString(h.Sum(nil)) return hex.EncodeToString(h.Sum(nil))
} }
func Sha256(str string) string {
h := sha256.New()
h.Write([]byte(str))
return hex.EncodeToString(h.Sum(nil))
}