UNPKG

luhn-generator

Version:

A generator of numbers that passes the validation of Luhn algorithm or Luhn formula, also known as the 'modulus 10' or 'mod 10' algorithm

14 lines (10 loc) 222 B
var crypto = require('crypto') var max = Math.pow(2, 32) module.exports = random module.exports.cryptographic = true function random () { var buf = crypto .randomBytes(4) .readUInt32BE(0) return buf / max }