|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcoderz.commons.util.LuhnAlgorithm
public final class LuhnAlgorithm
The Luhn algorithm. The Luhn algorithm or Luhn formula, also known as the modulus 10 or mod 10 algorithm, was developed in the 1960s as a method of validating identification numbers. It is a simple checksum formula used to validate a variety of account numbers, such as credit card numbers and Canadian Social Insurance Numbers. Much of its notoriety comes from credit card companies' adoption of it shortly after its creation in the late 1960s by IBM scientist Hans Peter Luhn (1896-1964). The algorithm is in the public domain and is in wide use today. It is not intended to be a cryptographically secure hash function; it protects against random error, not malicious attack. Most credit cards and many government identification numbers use the algorithm as a simple method of distinguishing valid numbers from collections of random digits.
| Method Summary | |
|---|---|
static boolean |
check(String cardNumber)
Execute the Luhn (Mod10) card check on a given card number. |
static int |
computeLuhnCardNumber(String cardNumberWithoutLastDigit)
Computes the Luhn check digit for a given card number. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean check(String cardNumber)
cardNumber - the card number to check.
public static int computeLuhnCardNumber(String cardNumberWithoutLastDigit)
cardNumberWithoutLastDigit - the card number without
the last digit.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||