校验密码是否有效
(hashing string, pass string)
| 49 | |
| 50 | //校验密码是否有效 |
| 51 | func 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 | |
| 67 | func hash(pass string, saltSecret string, salt string, interation int64) (string, error) { |
| 68 | var passSalt = saltSecret + pass + salt + saltSecret + pass + salt + pass + pass + salt |
no test coverage detected