mirror of
https://github.com/wumansgy/goEncrypt.git
synced 2025-09-26 19:51:27 +08:00
18 lines
245 B
Go
18 lines
245 B
Go
package hash
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
)
|
|
|
|
|
|
func Sha256Hex(data []byte) string {
|
|
return hex.EncodeToString(Sha256(data))
|
|
}
|
|
|
|
func Sha256(data []byte) []byte {
|
|
digest := sha256.New()
|
|
digest.Write(data)
|
|
return digest.Sum(nil)
|
|
}
|