Module codes_check_digits::luhn
source · Expand description
The type CheckDigitAlgorithm provides an implementation of the Luhn Algorithm.
Example
use codes_check_digits::{luhn, Calculator};
let calculator = luhn::get_algorithm_instance();
assert!(calculator.is_valid("US0378331005"));
assert!(calculator.validate("US0378331005").is_ok());
assert_eq!(calculator.calculate("US037833100"), Ok(5));Structs
This algorithm is known by many names: the “Luhn Formula”, “The IBM Check”,
“Mod 10”, and is officially specified in “Annex B to ISO/IEC 7812, Part 1”
and in “ANSI X4.13”. It is used as the check scheme on credit cards such
as Visa, Master Card, and American Express.