diff --git a/mycrypto/hash.go b/mycrypto/hash.go index 48d8769..33283ad 100644 --- a/mycrypto/hash.go +++ b/mycrypto/hash.go @@ -3,6 +3,7 @@ package mycrypto import ( "crypto/md5" "crypto/sha1" + "crypto/sha256" "encoding/hex" ) @@ -18,3 +19,9 @@ func Sha1(str string) string { h.Write([]byte(str)) return hex.EncodeToString(h.Sum(nil)) } + +func Sha256(str string) string { + h := sha256.New() + h.Write([]byte(str)) + return hex.EncodeToString(h.Sum(nil)) +}