Crate luhn_tools

Source
Expand description

Luhn algorithm implementation in Rust.

This crate provides functionality to generate and validate numbers using the Luhn algorithm, commonly used for validating various identification numbers such as credit card numbers, Canadian Social Insurance Numbers, and other identification numbers.

§Examples

use luhn_tools::{generate, validate, GenerateOptions};

// Generate a Luhn number
let result = generate("7992739871", None).unwrap();
assert_eq!(result, "79927398713");

// Validate a Luhn number
let is_valid = validate("79927398713").unwrap();
assert!(is_valid);

Structs§

GenerateOptions
Configuration options for generating Luhn numbers.

Enums§

LuhnError

Functions§

generate
Generates a Luhn number or checksum from the input value.
validate
Validates whether a number satisfies the Luhn algorithm.