mycommon/mycrypto/hash.go

21 lines
297 B
Go
Raw Normal View History

2023-05-17 13:57:50 +08:00
package mycrypto
import (
"crypto/md5"
"crypto/sha1"
"encoding/hex"
)
func Md5(str string) string {
h := md5.New()
h.Write([]byte(str))
return hex.EncodeToString(h.Sum(nil))
}
func Sha1(str string) string {
h := sha1.New()
h.Write([]byte(str))
return hex.EncodeToString(h.Sum(nil))
}