Skip to content

Instantly share code, notes, and snippets.

@evaletolab
Created March 9, 2016 10:13
Show Gist options
  • Save evaletolab/7f46f211ab4617c8e01e to your computer and use it in GitHub Desktop.
Save evaletolab/7f46f211ab4617c8e01e to your computer and use it in GitHub Desktop.
#!/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