Socket
Socket
Sign inDemoInstall

node-verhoeff

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-verhoeff - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

18

index.js

@@ -72,3 +72,20 @@ /*

function validateAadhaar(aadhaarString) {
if (aadhaarString.length != 12) {
return new Error('Aadhaar numbers should be 12 digit in length');
}
if (aadhaarString.match(/[^$,.\d]/)) {
return new Error('Aadhaar numbers must contain only numbers');
}
var aadhaarArray = aadhaarString.split('');
var toCheckChecksum = aadhaarArray.pop();
if (generate(aadhaarArray) == toCheckChecksum) {
return true;
} else {
return false;
}
};
module.exports = {};

@@ -78,1 +95,2 @@ module.exports.generate = generate;

module.exports.invArray = invArray;
module.exports.validateAadhaar = validateAadhaar;

2

package.json
{
"name": "node-verhoeff",
"version": "0.0.5",
"version": "0.0.6",
"description": "Simple implementation of verhoeff checksum algorithm",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,26 @@

# verhoeff
Simple implementation of node verhoeff
# Verhoeff
Simple implementation of verhoeff checksum implentation in node JS.
#### Aadhaar numbers & verhoeff
Did you know aadhaar numbers have last digit as a verhoeff checksum. The idea behind this is to quickly identify typing/data-entry errors on the entry machine.
https://groups.google.com/forum/#!msg/aadhaarauth/eB5hOU-Qtq0/YDcWPdPOXowJ
# Usage
```sh
npm i node-verhoeff --save
```
```js
var verhoeff = require('node-verhoeff');
verhoeff.validateAadhaar('496858245152')
// should return true
verhoeff.generate([4, 9, 6, 8, 5, 8, 2, 4, 5, 1, 5]);
// should return 2, generates verhoeff checksum using the input array
```
##### Original code by
Sergey Petushkov, 2014
##### Understand the math
For more info on the algorithm: http://en.wikipedia.org/wiki/Verhoeff_algorithm
by

@@ -13,2 +13,7 @@ var thisModule = require('../index.js');

});
it('Should validate aadhaar correctly', function() {
expect(thisModule.validateAadhaar('773393045190')).to.equal(true);
expect(thisModule.validateAadhaar('773393045191')).to.equal(false);
expect(thisModule.validateAadhaar('496858245152')).to.equal(true);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc