(length int)
| 135 | } |
| 136 | |
| 137 | func GenerateSecret(length int) (secret string, hashed []byte, err error) { |
| 138 | secret, err = cryptorand.String(length) |
| 139 | if err != nil { |
| 140 | return "", nil, err |
| 141 | } |
| 142 | hash := HashSecret(secret) |
| 143 | return secret, hash, nil |
| 144 | } |
| 145 | |
| 146 | // ValidateHash compares a secret against an expected hashed secret. |
| 147 | func ValidateHash(hashedSecret []byte, secret string) bool { |