pub fn get_check_digit(input: &str) -> u8Expand description
Compute the MRZ check digit for input.
The algorithm:
- For each character, map it to a numeric value:
- ‘A’..‘Z’ -> 10 + (ch - ‘A’)
- ‘0’..‘9’ -> ch - ‘0’
- otherwise -> 0
- Multiply each value by the repeating weights [7,3,1] at its index.
- Sum the products and return (sum % 10) as the check digit.
Example:
assert_eq!(mrz_parser::get_check_digit("L898902C3"), 6);