2 unstable releases
new 0.2.0 | Jan 14, 2025 |
---|---|
0.1.2 | Nov 7, 2023 |
0.1.1 |
|
0.1.0 |
|
#79 in Internationalization (i18n)
68 downloads per month
14KB
115 lines
中国(大陆)18位身份证号码检查
=======================
身份证号码说明
- 身份证号码由17位数字本体码和1位数字校验码组成。
- 身份证号码组成(按索引,如下图):
- 0-5 地址码
- 6-13 出生年月日
- 14-16 顺序码
- 16 奇数代表男性,偶数代表女性
- 17 校验码
- 验证规则如下:
- a. 将身份证号码前17位数分别乘以不同的系数。
- b. 将相乘的所有结果相加。
- c. 将和与11取余数。
- d. 将余数为索引找到对应校验码。
- e. 和第17位进行比较,检查是否相等。
图片来源网络
Bench
-
Test Host Apple Mac mini 2023 M2 chip 16GB mem
-
golang
$ go test -benchmem -run=^$ -bench ^BenchmarkParse$
goos: darwin
goarch: arm64
pkg: github.com/cuipeiyu/china-id
cpu: Apple M3
BenchmarkParse-8 5089683 217.1 ns/op 72 B/op 2 allocs/op
PASS
ok github.com/cuipeiyu/china-id 1.506s
- rust
$ cargo bench
Compiling china-id v0.2.0 (/Users/cui/Projects/github.com/cuipeiyu/china-id)
Finished `bench` profile [optimized] target(s) in 1.02s
Running unittests src/lib.rs (target/release/deps/china_id-2b398abde40a8aa0)
running 1 test
test tests::ut_parse ... ignored
test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running benches/benchmark.rs (target/release/deps/benchmark-a5b3e825dae2b1bc)
Gnuplot not found, using plotters backend
bench time: [376.95 ns 377.95 ns 378.92 ns]
change: [-11.373% -3.9953% +1.8492%] (p = 0.34 > 0.05)
No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild
Dependencies
~1MB
~18K SLoC