voucher-generator
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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

Package Sidebar

Install

npm i voucher-generator

Weekly Downloads

4

Version

2.0.0

License

MIT

Unpacked Size

7.83 kB

Total Files

4

Last publish

Collaborators

  • iyiolapeter