Skip to main content

generate

Function generate 

Source
pub fn generate(count: usize) -> Vec<(String, String)>
Expand description

Generates count one-time backup recovery codes.

Each code is formatted as xxxx-xxxx (8 lowercase alphanumeric characters split by a hyphen). Returns a Vec of (plaintext_code, sha256_hex_hash) tuples. Store only the hashes; display the plaintext codes to the user once. Verify a submitted code with verify.

Uses rejection sampling over OsRng to avoid modulo bias.

Requires feature "auth".