Expand description
§iso7064 — ISO 7064 MOD 97-10 check characters
Compute and validate ISO 7064 MOD 97-10 check characters — the algorithm behind
LEI codes, IBAN check digits, and
more. A faithful Rust port of the
iso-7064 npm package, plus the standard
validation and check-digit-generation helpers.
use iso7064::{compute, generate_check_digits, is_valid};
// The MOD 97 of a string (the reference's `compute`):
assert_eq!(compute("969500KSV493XWY0PS").unwrap(), 54);
// Generate the two check digits for a base, and validate the whole code:
assert_eq!(generate_check_digits("969500KSV493XWY0PS").unwrap(), "33");
assert!(is_valid("969500KSV493XWY0PS33"));Zero dependencies and #![no_std].
Enums§
- Error
- An error from a checked operation.
Functions§
- compute
- Compute the MOD 97 of
value, after checking it matches[0-9A-Z]+. - compute_
without_ check - Compute the MOD 97 of
valuewithout validating its format. - generate_
check_ digits - Generate the two MOD 97-10 check digits for
base(the code without its check digits). - is_
valid - Whether
valueis a valid ISO 7064 MOD 97-10 code (its MOD 97 equals 1).