codes-check-digits

Common implementation of check digit algorithms

3 releases

0.1.2 Dec 25, 2022
0.1.1 Dec 23, 2022
0.1.0 Dec 22, 2022
Download history 75/week @ 2024-07-19 74/week @ 2024-07-26 37/week @ 2024-08-02 64/week @ 2024-08-09 29/week @ 2024-08-16 12/week @ 2024-08-23 11/week @ 2024-08-30 32/week @ 2024-09-06 6/week @ 2024-09-13 13/week @ 2024-09-20 26/week @ 2024-09-27 14/week @ 2024-10-04 83/week @ 2024-10-11 40/week @ 2024-10-18 131/week @ 2024-10-25 41/week @ 2024-11-01

297 downloads per month
Used in 4 crates (3 directly)

MIT and maybe LGPL-3.0+

63KB
1K SLoC

Package codes-check-digits

This package contains implementations of various check digit specifications, including ISO/IEC 7064:2003 Information technology — Security techniques — Check character systems.

crates.io docs.rs

For notes on the design of the API, see the repository README.

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));

Features

  • gs1 - Adds the gs1 module containing algorithms for various codes such as EAN, GTIN, GLN, and UPC.
  • iso_7064 - Adds the iso_7064 module containing implementations of the variants defined in ISO/IEC 7064:2003.
  • luhn - Adds the luhn module containing an implementation of the Luhn Algorithm.
  • sedol - Adds the sedol module containing an implementation of the algorithm used in SEDOL numbers.

Changes

Version 0.1.2

  • Made all NSIN types also Code implementations

Version 0.1.1

  • rug integers not building on Windows, gated the feature for now.

Version 0.1.0

  • Initial release, copied from packages codes-common, codes-iso-6166, codes-iso-17442, and codes-gs1-gln.

TODO

TBD

Dependencies

~0.3–4MB
~85K SLoC