Skip to main content

generate_key

Function generate_key 

Source
pub fn generate_key() -> Result<(String, String, String), ApiKeyError>
Expand description

Generate a fresh API key. Returns (full_token, prefix, hash):

  • full_token โ€” {prefix}.{secret} to give to the user
  • prefix โ€” 8-char hex prefix for the lookup column
  • hash โ€” argon2id hash of the secret for the password column

ยงErrors

ApiKeyError::Hash on argon2 failures (extremely rare).