SlxLuhnLibrary 1.0.0
See the version list below for details.
dotnet add package SlxLuhnLibrary --version 1.0.0
NuGet\Install-Package SlxLuhnLibrary -Version 1.0.0
<PackageReference Include="SlxLuhnLibrary" Version="1.0.0" />
paket add SlxLuhnLibrary --version 1.0.0
#r "nuget: SlxLuhnLibrary, 1.0.0"
// Install SlxLuhnLibrary as a Cake Addin #addin nuget:?package=SlxLuhnLibrary&version=1.0.0 // Install SlxLuhnLibrary as a Cake Tool #tool nuget:?package=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 non-numeric 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 '*'");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SlxLuhnLibrary:
Package | Downloads |
---|---|
Rangerus.RSAIDGen
Simple to use library for generating Random but valid south african id numbers |
GitHub repositories
This package is not used by any popular GitHub repositories.