pub fn generate_code(
secret_key: &[u8; 32],
counter: u64,
alphabet: &Alphabet,
code_length: usize,
check_position: CheckPosition,
damm_table: &DammTable,
) -> StringExpand description
Generate a single promotional code from a counter value.
§Arguments
secret_key- 32-byte secret key for HMACcounter- Counter value (unique per code)alphabet- Character set for the codecode_length- Number of random characters (check digit added separately)check_position- Where to place the check digit (index-based)damm_table- Damm table for check digit calculation
§Returns
Generated code string with length = code_length + 1 (including check digit)
§Example
use promocrypt_core::{generate_code, Alphabet, DammTable, CheckPosition};
let secret = [0u8; 32];
let alphabet = Alphabet::default_alphabet();
let damm = DammTable::new(alphabet.len());
let code = generate_code(&secret, 0, &alphabet, 9, CheckPosition::End, &damm);
assert_eq!(code.len(), 10);