-
-
Save DC3/d3e9f066f23852af5d0eee82939029f9 to your computer and use it in GitHub Desktop.
ID card verify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
verify = (idcard) -> | |
factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] | |
mask = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2] | |
idcard[idcard.length - 1] is mask[((x * factor[i] for x, i in idcard[0...idcard.length - 1]).reduce (x, y) -> x + y) % mask.length].toString() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment