#numbers #identification #idcard #id-card-number

cn-id-card

Chinese identification card number verification, including region code, birthday, and check code

8 releases

0.1.8 May 23, 2023
0.1.7 Apr 9, 2023
0.1.3 May 3, 2022
0.1.2 Mar 20, 2022

#3 in #identification

Apache-2.0

325KB
6.5K SLoC

Fork of https://github.com/Ethan1225/id-card-rust

cn-id-card

Chinese person identification card number verification, including region code, birthday, and check code. Chinese unified social credit code verification, including check code only.

License

APL 2.0, see LICENSE file.

Installation

In Cargo.toml add

[dependencies]
cn-id-card="0.1"

Then re-run cargo build. That fetches the dependencies and builds the code.

Usage

extern crate cn_id_card;

fn main() {
    println!("{}", cn_id_card::validate("440524188001010014", true));//outputs: true
    println!("{}", cn_id_card::validate_code("12100000400009880K", true));//outputs: true
}

Development

Test changes before commitment.(Install nightly if it haven't been installed: rustup install nightly)

cargo clean
cargo fmt --all -- --check
cargo build
cargo +nightly bench
cargo test

Dependencies

~3–4.5MB
~72K SLoC