package ncrypt import ( "crypto/sha1" "crypto/sha256" "crypto/sha512" "encoding/hex" ) // Sha1 return the sha1 value (SHA-1 hash algorithm) of string. func Sha1(data string) string { s := sha1.New() s.Write([]byte(data)) return hex.EncodeToString(s.Sum([]byte(""))) } // Sha256 return the sha256 value (SHA256 hash algorithm) of string. func Sha256(data string) string { s := sha256.New() s.Write([]byte(data)) return hex.EncodeToString(s.Sum([]byte(""))) } // Sha512 return the sha512 value (SHA512 hash algorithm) of string. func Sha512(data string) string { s := sha512.New() s.Write([]byte(data)) return hex.EncodeToString(s.Sum([]byte(""))) }