MCPcopy Index your code
hub / github.com/coder/coder / ValidateHash

Function ValidateHash

coderd/apikey/apikey.go:147–150  ·  view source on GitHub ↗

ValidateHash compares a secret against an expected hashed secret.

(hashedSecret []byte, secret string)

Source from the content-addressed store, hash-verified

145
146// ValidateHash compares a secret against an expected hashed secret.
147func 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.

Callers 9

ExtractWorkspaceProxyFunction · 0.92
TestGenerateFunction · 0.92
TestInvalidFunction · 0.92
IsAuthorizedMethod · 0.92
revokeRefreshTokenInTxFunction · 0.92
authorizationCodeGrantFunction · 0.92
refreshTokenGrantFunction · 0.92

Calls 1

HashSecretFunction · 0.70

Tested by 2

TestGenerateFunction · 0.74
TestInvalidFunction · 0.74