MCPcopy Index your code
hub / github.com/TruthHun/BookStack / PasswordHash

Function PasswordHash

utils/password.go:24–48  ·  view source on GitHub ↗

加密密码

(pass string)

Source from the content-addressed store, hash-verified

22
23//加密密码
24func PasswordHash(pass string) (string, error) {
25
26 saltSecret, err := saltSecret()
27 if err != nil {
28 return "", err
29 }
30
31 salt, err := salt(saltLocalSecret + saltSecret)
32 if err != nil {
33 return "", err
34 }
35
36 interation := randInt(1, 20)
37
38 hash, err := hash(pass, saltSecret, salt, int64(interation))
39 if err != nil {
40 return "", err
41 }
42
43 interationStr := strconv.Itoa(interation)
44 password := saltSecret + delimiter + interationStr + delimiter + hash + delimiter + salt
45
46 return password, nil
47
48}
49
50//校验密码是否有效
51func PasswordVerify(hashing string, pass string) (bool, error) {

Callers 5

ValidEmailMethod · 0.92
PasswordMethod · 0.92
EditMemberMethod · 0.92
ChangePasswordMethod · 0.92
AddMethod · 0.92

Calls 4

saltSecretFunction · 0.85
saltFunction · 0.85
randIntFunction · 0.85
hashFunction · 0.85

Tested by

no test coverage detected