luhnify
Generate random Luhn sequences, such as credit card numbers.
Last updated 7 months ago by koopero .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install luhnify 
SYNC missed versions from official npm registry.

Luhnify

A simply node.js module to generate random Luhn algorithm sequences.

Example

var luhnify = require('luhnify')

// Random visa credit card number.
var cc = luhnify( '4### #### #### ####' )

// Random Canadian social insurance number.
var sin = luhnify( '###-###-###' )

// Also, validate sequences
luhnify.validate( sin ) === true
luhnify.validate( '123' ) === false

API

luhnify( sequence, token='#' )

Replace all token characters in sequence with digits between 0-9 and return a valid Luhn sequence.

If a Number is provided, a sequence of that many digits will be returned.

The token argument will specific a token to replace other than '#'. This token must be a single character.

If no valid sequence can be generated ( no tokens to replace ), an Error will be thrown.

validate( sequence )

Return true if a sequence is valid or false if it is not.

Current Tags

  • 1.1.1                                ...           latest (7 months ago)

3 Versions

  • 1.1.1                                ...           7 months ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |