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

Function PasswordVerify

utils/password.go:51–65  ·  view source on GitHub ↗

校验密码是否有效

(hashing string, pass string)

Source from the content-addressed store, hash-verified

49
50//校验密码是否有效
51func PasswordVerify(hashing string, pass string) (bool, error) {
52 data := trimSaltHash(hashing)
53
54 interation, _ := strconv.ParseInt(data["interation_string"], 10, 64)
55
56 has, err := hash(pass, data["salt_secret"], data["salt"], int64(interation))
57 if err != nil {
58 return false, err
59 }
60
61 if (data["salt_secret"] + delimiter + data["interation_string"] + delimiter + has + delimiter + data["salt"]) == hashing {
62 return true, nil
63 }
64 return false, nil
65}
66
67func hash(pass string, saltSecret string, salt string, interation int64) (string, error) {
68 var passSalt = saltSecret + pass + salt + saltSecret + pass + salt + pass + pass + salt

Callers 6

PasswordMethod · 0.92
ChangePasswordMethod · 0.92
LoginMethod · 0.92
LoginedBindWechatMethod · 0.92
LoginBindWechatMethod · 0.92
LoginMethod · 0.92

Calls 2

trimSaltHashFunction · 0.85
hashFunction · 0.85

Tested by

no test coverage detected