
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
luhn-string
Advanced tools
A library to generate strings that end with a checksum 'digit'. Digits in the string are in the range 0-9B-DF-HJ-NP-TV-XZ. All uppercase.
A library to generate alphanumeric strings that end with a checksum "digit". Digits in the string are in the range 0-9B-DF-HJ-NP-TV-XZ. All uppercase.
Changed in v1.2.0 > provide your own character sequence using var cardLuhn = require('luhn-string')('0123456789'); where '0123456789' is the valid character sequence for the strings you want to generate. Call on the generated object as always.
1.2.0. Rather than having to send the valid caharacters sequence for every call, the main Luhn Object has been upgraded to be a factory for LuhnObjects. Check sample.js for updated samples
1.1.0. All functions allow you specify a string of valid characters in case you do not want the default of 0-9A-Z excluding vowels and Y. Callbacks can still be sent. All results are still Uppercase. Note that the characters must be in same order when you are validating. A random string generated with sequence '0123456789' will not validate correctly against sequence '9876543210'.
npm install luhn-string -save
var Luhn = require('luhn-string');
// to generate a 16-digit checksummed string
var str = Luhn.random(16);
console.log(str);
// to generate a 16-digit checksummed string with 0123456789 as sequence
// Method 1
var res = Luhn.random(16, '0123456789');
console.log(res);
console.log(Luhn.check(res, '0123456789'));
// Method 2
var creator = new Luhn('0123456789');
res = creator.random(16);
console.log(res);
console.log(creator.check(res));
// to test a string for checksum validity
var chk = Luhn.check('30MFLRQDVCFQ9SK1');
var valid = chk.result;
var validityerror = chk.error;
// Use callbacks
Luhn.random(16, function(error, result){
if(error){
// do something with error...
return;
}
console.log(result);
});
Luhn.check('LH989002BW3P', function(error, result){
if(error){
// do something with error...
return;
}
console.log(result); // true or false
});
The library uses a crypto function to generate random strings. This is Exposed for your use in 2 forms:
returns a truly random ascii string of length length
returns a truly random ascii string of length length, picking characters in string chars
checks that str contains valid characters and appends a checksum character at its end. Should be used in callback fashion. Returns null if there is an error otherwise.
FAQs
A library to generate strings that end with a checksum 'digit'. Digits in the string are in the range 0-9B-DF-HJ-NP-TV-XZ. All uppercase.
The npm package luhn-string receives a total of 468 weekly downloads. As such, luhn-string popularity was classified as not popular.
We found that luhn-string demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.