Created
March 9, 2016 10:13
-
-
Save evaletolab/7f46f211ab4617c8e01e to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/node | |
function luhnMod10 (bvr){ | |
var k, I=0; | |
var zr_post = "0946827135094682713" ; | |
for (var J = 0 ; J< bvr.length; J++){ | |
k = parseInt(bvr.charAt(J)); | |
I = parseInt(zr_post.charAt(I+k)); | |
} | |
return (10-I) % 10; | |
}; | |
function validBVR(ref) { | |
var luhn=luhnMod10 (ref.substring(0, ref.length-1)); | |
return (luhn) == parseInt(ref.charAt(ref.length -1)) ; | |
}; | |
console.log('valid 052789000583104300002534930',validBVR('052789000583104300002534930')); | |
console.log('valid 001141636433009254020220167',validBVR('001141636433009254020220167')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment