mirror of
https://github.com/wumansgy/goEncrypt.git
synced 2025-09-26 19:51:27 +08:00
23 lines
323 B
Go
23 lines
323 B
Go
package goEncrypt
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
)
|
|
|
|
/*
|
|
@Time : 2018/11/2 17:05
|
|
@Author : wuman
|
|
@File : sha256
|
|
@Software: GoLand
|
|
*/
|
|
|
|
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)
|
|
} |