dual check v0.1

This commit is contained in:
cancerai committed 2026-08-29 23:34:01 +08:00
1 parent 78bad1fa3d
commit c137299016
36 files changed
+3727 -81

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
// Package hash 提供 SHA-256 哈希工具
package hash
import (
"crypto/sha256"
"encoding/hex"
)
// SHA256 返回输入字符串的 SHA-256 十六进制哈希
// 注意:故意不加盐(bcrypt 会自动加盐但输出包含盐值),
// 因为我们的场景是"判断两段明文是否相同",
// 只要对两端的明文做同样的 hash 即可比较,无需加盐。
func SHA256(input string) string {
h := sha256.Sum256([]byte(input))
return hex.EncodeToString(h[:])
}