package crypto import ( "crypto/sha1" "crypto/sha256" "crypto/sha512" "encoding/hex" ) // Sha1Encode return the sha1 value (SHA-1 hash algorithm) of string func (c *Crypto) Sha1Encode(data string) string { sha1 := sha1.New() sha1.Write([]byte(data)) return hex.EncodeToString(sha1.Sum([]byte(""))) } // Sha256Encode Sha256加密 func (c *Crypto) Sha256Encode(src string) string { m := sha256.New() m.Write([]byte(src)) res := hex.EncodeToString(m.Sum(nil)) return res } // Sha512Encode return the sha512 value (SHA512 hash algorithm) of string func (c *Crypto) Sha512Encode(data string) string { sha512 := sha512.New() sha512.Write([]byte(data)) return hex.EncodeToString(sha512.Sum([]byte(""))) }