voucher-generator
v2.0.0
Published
Crytography secure random number generator written in TypeScript suitable for numeric vouchers, recharge cards or coupon codes
Downloads
28
Maintainers
Readme
voucher-generator
Crytography secure random number generator written in TypeScript suitable for numeric vouchers, recharge cards or coupon codes
Installation
$ npm install --save voucher-generator
Usage
import { calculateCheck, generate, GenerateOptions } from "voucher-generator"
let options: GenerateOptions = {
length: 16,
check: true // makes the last digit a check digit using luhn algorithm
}
or
const { calculateCheck, generate } = require("voucher-generator")
let options = {
length: 16,
check: true // makes the last digit a check digit using luhn algorithm
}
then
Generate
console.log(generate(options)) // 7641304460542031
Calculate Check Digit
console.log(calculateCheck('764130446054203')) // 1
Testing
$ npm test