Click here to Skip to main content
Licence 
First Posted 8 Dec 2004
Views 30,370
Bookmarked 13 times

Luhn' s Algorithm

By | 8 Dec 2004 | Article
Calculating checksum number using Luhn's algorithm

Introduction

This sample implements the functionality of generating checksum number using Luhn's algorithm.

I've created a class LuhnAlgorithm with a static function:

public static int GetLuhnAlgorithmNumber(string data);

Return value is the generated number.

Definition

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).

Explanation of the Luhn's algorithm can be found here.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

wapnethr



Austria Austria

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralActually, this method only needs one line changed to compute the correct Luhn check-digit (the "return" equation is wrong) Pinmemberkirkaiya18:42 6 Aug '09  
QuestionIncorrect Algorithm? PinmemberPeebles2:36 3 Mar '05  
Generaluse this code... PinmemberJoel Thoms11:47 18 Jan '05  
Questionhow to use PinmemberJoel Thoms11:41 18 Jan '05  
Generalwrote an implementation myslef some time ago Pinmember
MadHatter ¢
7:02 9 Dec '04  
GeneralExplaining my vote PinmemberJason De Arte8:45 8 Dec '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 8 Dec 2004
Article Copyright 2004 by wapnethr
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid