SlxLuhnLibrary 1.0.0
# SlxLuhnLibrary
[The Luhn algorithm](https://en.wikipedia.org/wiki/Luhn_algorithm) or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers in the United States, Canadian Social Insurance Numbers, Israel ID Numbers and Greek Social Security Numbers (ΑΜΚΑ). It was created by IBM scientist Hans Peter Luhn and described in U.S. Patent No. 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.
Here I implement the [Luhn mod N algorithm](https://en.wikipedia.org/wiki/Luhn_mod_N_algorithm) which is an extension to the Luhn algorithm (also known as mod 10 algorithm) that allows it to work with sequences of nonnumeric characters. This can be useful when a check digit is required to validate an identification string composed of letters, a combination of letters and digits or even any arbitrary set of characters.
See the version list below for details.
InstallPackage SlxLuhnLibrary Version 1.0.0
dotnet add package SlxLuhnLibrary version 1.0.0
<PackageReference Include="SlxLuhnLibrary" Version="1.0.0" />
paket add SlxLuhnLibrary version 1.0.0
SlxLuhnLibrary
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers in the United States, Canadian Social Insurance Numbers, Israel ID Numbers and Greek Social Security Numbers (ΑΜΚΑ). It was created by IBM scientist Hans Peter Luhn and described in U.S. Patent No. 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.
Here I implement the Luhn mod N algorithm which is an extension to the Luhn algorithm (also known as mod 10 algorithm) that allows it to work with sequences of nonnumeric characters. This can be useful when a check digit is required to validate an identification string composed of letters, a combination of letters and digits or even any arbitrary set of characters.
To test:
 Generate a new string with the luhn verification charater for a string (composed with modulo 10 caracters) :
ClsLuhnLibrary.WithLuhn_Base10("35823805800008");
// Returns "358238058000088"
 Generate the luhn verification charater for a string (composed with modulo 10 caracters) :
ClsLuhnLibrary.GenerateCheckCharacter("453908962903274", ClsLuhnLibrary.CharacterSet.Base10);
// Returns '4'
 Validate a composed with modulo 10 characters String :
ClsLuhnLibrary.ValidateCheckCharacter("4539089629032744", ClsLuhnLibrary.CharacterSet.Base10);
// Returns true
Bonus Points
You've got the same thing for built in Base36_0to9_atoz
, Base62_0to9_atoz_AtoZ
, and user set of characters
ClsLuhnLibrary.Init_BaseUser(new Char[] { '#', '!', '*' });
String str = "**##!!";
Char? cRc = ClsLuhnLibrary.GenerateCheckCharacter(str, ClsLuhnLibrary.CharacterSet.BaseUser);
Assert.AreEqual('*', cRc, $"The result of GenerateCheckCharacter for {str} is '*'");
SlxLuhnLibrary
The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers in the United States, Canadian Social Insurance Numbers, Israel ID Numbers and Greek Social Security Numbers (ΑΜΚΑ). It was created by IBM scientist Hans Peter Luhn and described in U.S. Patent No. 2,950,048, filed on January 6, 1954, and granted on August 23, 1960.
Here I implement the Luhn mod N algorithm which is an extension to the Luhn algorithm (also known as mod 10 algorithm) that allows it to work with sequences of nonnumeric characters. This can be useful when a check digit is required to validate an identification string composed of letters, a combination of letters and digits or even any arbitrary set of characters.
To test:
 Generate a new string with the luhn verification charater for a string (composed with modulo 10 caracters) :
ClsLuhnLibrary.WithLuhn_Base10("35823805800008");
// Returns "358238058000088"
 Generate the luhn verification charater for a string (composed with modulo 10 caracters) :
ClsLuhnLibrary.GenerateCheckCharacter("453908962903274", ClsLuhnLibrary.CharacterSet.Base10);
// Returns '4'
 Validate a composed with modulo 10 characters String :
ClsLuhnLibrary.ValidateCheckCharacter("4539089629032744", ClsLuhnLibrary.CharacterSet.Base10);
// Returns true
Bonus Points
You've got the same thing for built in Base36_0to9_atoz
, Base62_0to9_atoz_AtoZ
, and user set of characters
ClsLuhnLibrary.Init_BaseUser(new Char[] { '#', '!', '*' });
String str = "**##!!";
Char? cRc = ClsLuhnLibrary.GenerateCheckCharacter(str, ClsLuhnLibrary.CharacterSet.BaseUser);
Assert.AreEqual('*', cRc, $"The result of GenerateCheckCharacter for {str} is '*'");
Dependencies

.NETStandard 2.0
 No dependencies.
GitHub Usage
This package is not used by any popular GitHub repositories.