123456789101112131415161718192021222324252627 |
- package hash
- import (
- "crypto/sha256"
- "crypto/sha512"
- "encoding/hex"
- )
- func SHA256(value string) string {
- sum := sha256.Sum256([]byte(value))
- hash := []byte{}
- for _, b := range sum {
- hash = append(hash, b)
- }
- return hex.EncodeToString(hash)
- }
- func SHA512(value string) string {
- sum := sha512.Sum512([]byte(value))
- hash := []byte{}
- for _, b := range sum {
- hash = append(hash, b)
- }
- return hex.EncodeToString(hash)
- }
|