3 releases (stable)

1.0.1 Aug 28, 2020
1.0.0 Sep 24, 2019
0.1.0 Aug 20, 2015

#85 in Finance

Download history 5519/week @ 2024-12-09 7148/week @ 2024-12-16 762/week @ 2024-12-23 2426/week @ 2024-12-30 4937/week @ 2025-01-06 5339/week @ 2025-01-13 6220/week @ 2025-01-20 6112/week @ 2025-01-27 6034/week @ 2025-02-03 6078/week @ 2025-02-10 4802/week @ 2025-02-17 7033/week @ 2025-02-24 7670/week @ 2025-03-03 7854/week @ 2025-03-10 5570/week @ 2025-03-17 4261/week @ 2025-03-24

25,391 downloads per month
Used in 4 crates

MIT license

9KB
131 lines

luhn-rs

Validates strings and computes check digits using the Luhn algorithm.

Usage

Add luhn under [dependencies] in your Cargo.toml:

[dependencies]
luhn = "1.0.1"

Use the validator!

luhn::valid("4111111111111111"); // true

Append check digits to your strings and make them Luhn-valid!

// A string which doesn't validate
let mut s = "11111111".to_string();
assert!(!valid(&s));

// Let's fix that
s.push(luhn::checksum(s.as_bytes()) as char);
assert_eq!(s, "111111118");
assert!(valid(&s));

Dependencies

~11KB