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

Function GenerateSecret

coderd/apikey/apikey.go:137–144  ·  view source on GitHub ↗
(length int)

Source from the content-addressed store, hash-verified

135}
136
137func 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.
147func ValidateHash(hashedSecret []byte, secret string) bool {

Callers 11

randomAPIKeyPartsFunction · 0.92
NewFunction · 0.92
APIKeyFunction · 0.92
WorkspaceProxyFunction · 0.92
TestInvalidFunction · 0.92
TestAuthorizationFunction · 0.92
GenerateSecretFunction · 0.92
GenerateFunction · 0.70

Calls 2

StringFunction · 0.92
HashSecretFunction · 0.70

Tested by 4

randomAPIKeyPartsFunction · 0.74
TestInvalidFunction · 0.74
TestAuthorizationFunction · 0.74