From 49b5ec8cd8909fb5678833afa3fe0c3c25643c96 Mon Sep 17 00:00:00 2001 From: lizifeng Date: Wed, 17 May 2023 14:02:34 +0800 Subject: [PATCH] update --- mycrypto/hash.go | 7 +++++++ 1 file changed, 7 insertions(+) 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)) +}