Skip to content
/ luhn_gem Public

Luhn checksum algorithm, credit card generation and validation

License

Notifications You must be signed in to change notification settings

pliam/luhn_gem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

= Luhn Gem

Luhn checksum algorithm gem, credit card generation and validation


== Usage

While credit card validation routines abound, it's still nice have a window open and 
crank out test cards during web development:

  $ irb -rubygems -r luhn
  irb(main):001:0> Luhn.generate  
  => "4354135477199499" # defaults to :visa, but also can be in [:mast,:disc,:amex]
  irb(main):002:0> Luhn.generate(:visa)
  => "4076900550063889"

Of course if you just want the Luhn checksum, you can do:

  Luhn.checksum("1234321") # => 4

To validate the checksum of a decimal string (as opposed to the full-context validity)

  Luhn.checksum_valid?("1234321")          # => false
  Luhn.checksum_valid?("4076900550063889") # => true
  Luhn.checksum_valid?("4076900550063888") # => false


= Downloading

Note: not yet registered as a rubyforge gem

git://github.com/pliam/luhn_gem.git


= Copying

Copyright (c) 2008 John Pliam, released under the MIT license

About

Luhn checksum algorithm, credit card generation and validation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages