mirror of
https://github.com/yv1ing/gin-admin.git
synced 2025-10-24 10:12:05 +08:00
23 lines
379 B
Go
23 lines
379 B
Go
package encrypt
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
)
|
|
|
|
// @Author: yv1ing
|
|
// @Author: me@yvling.cn
|
|
// @Date: 2025/8/28 17:15
|
|
// @Desc: 计算Sha256哈希值
|
|
|
|
func Sha256String(text, salt string) string {
|
|
textBytes := []byte(text)
|
|
saltBytes := []byte(salt)
|
|
|
|
hash := sha256.New()
|
|
hash.Write(textBytes)
|
|
hash.Write(saltBytes)
|
|
|
|
return hex.EncodeToString(hash.Sum(nil))
|
|
}
|