github.com/LagrangeDev/LagrangeGo@v0.0.0-20240512064304-ad4a85e10cb4/utils/crypto/hash.go (about) 1 package crypto 2 3 import ( 4 "crypto/md5" 5 "crypto/sha1" 6 "crypto/sha256" 7 ) 8 9 func MD5Digest(v []byte) []byte { 10 h := md5.New() 11 h.Write(v) 12 return h.Sum(make([]byte, 0, md5.Size)) 13 } 14 15 func SHA256Digest(v []byte) []byte { 16 h := sha256.New() 17 h.Write(v) 18 return h.Sum(make([]byte, 0, sha256.Size)) 19 } 20 21 func SHA1Digest(v []byte) []byte { 22 h := sha1.New() 23 h.Write(v) 24 return h.Sum(make([]byte, 0, sha1.Size)) 25 }