ValidateHash compares a secret against an expected hashed secret.
(hashedSecret []byte, secret string)
| 145 | |
| 146 | // ValidateHash compares a secret against an expected hashed secret. |
| 147 | func ValidateHash(hashedSecret []byte, secret string) bool { |
| 148 | hash := HashSecret(secret) |
| 149 | return subtle.ConstantTimeCompare(hashedSecret, hash) == 1 |
| 150 | } |
| 151 | |
| 152 | // HashSecret is the single function used to hash API key secrets. |
| 153 | // Use this to ensure a consistent hashing algorithm. |