1
0
mirror of https://github.com/fumiama/tienyik.git synced 2026-07-01 16:30:26 +08:00

feat: add more apis

This commit is contained in:
源文雨
2025-10-31 23:20:46 +08:00
parent 15fcc9a338
commit da1de770ad
19 changed files with 509 additions and 82 deletions

25
sha256.go Normal file
View File

@@ -0,0 +1,25 @@
package tienyik
import (
"crypto/sha256"
"encoding/hex"
)
func ChallengePassword(pwd string, chlg string) string {
h := sha256.New()
h.Write([]byte(pwd))
h.Write([]byte(chlg))
var sum [sha256.Size]byte
return hex.EncodeToString(h.Sum(sum[:0]))
}
func ChallengeSHA256Password(pwd string, chlg string) string {
h := sha256.New()
h.Write([]byte(pwd))
var sum [sha256.Size]byte
s := hex.EncodeToString(h.Sum(sum[:0]))
h.Reset()
h.Write([]byte(s))
h.Write([]byte(chlg))
return hex.EncodeToString(h.Sum(sum[:0]))
}