C# library that provide ISO 7064 implementations to verify or calculate check characters.
Out of the box, the library supports the following pure systems:
- Modulus 11 with Radix 2
- Modulus 37 with Radix 2
- Modulus 97 with Radix 10
- Modulus 661 with Radix 26
- Modulus 1271 with Radix 36
This library can be installed via NuGet package. Just run the following command:
Install-Package SimpleISO7064
This library directly targets the following frameworks:
- .NET Standard 1.0;
- .NET Standard 2.0;
- .NET Framework 2.0;
- .NET Framework 4.0;
- .NET 5.0;
Basic example (using Mod 11 Radix 2 singleton):
const string value = "101100002683118740";
IIso7064PureSystemProvider provider = Iso7064.PureSystem.Mod11Radix2;
// computes the check digit -> 7
var checkDigit = provider.ComputeCheckDigit(value);
// computes the value with the check digit -> 1011000026831187407
var computed = provider.Compute(value);
// checks if the value is valid -> true
var isValid = provider.IsValid(computed);
Out of the box pure systems are available in the Iso7064.PureSystem
namespace.
var mod11Radix2 = new Mod11Radix2();
var mod37Radix2 = new Mod37Radix2();
var mod97Radix10 = new Mod97Radix10();
var mod661Radix26 = new Mod661Radix26();
var mod1271Radix36 = new Mod1271Radix36();
Since the pure system implementations are thread safe, it is recommended to use the singleton instances available in the Iso7064.PureSystem
class.
var mod11Radix2 = Iso7064.PureSystem.Mod11Radix2;
var mod37Radix2 = Iso7064.PureSystem.Mod37Radix2;
var mod97Radix10 = Iso7064.PureSystem.Mod97Radix10;
var mod661Radix26 = Iso7064.PureSystem.Mod661Radix26;
var mod1271Radix36 = Iso7064.PureSystem.Mod1271Radix36;
You can also create your own pure systems either by creating a new instance of Iso7064PureSystemProvider
, using the
builder method provided by the Iso7064Factory
class or by implementing the IIso7064PureSystemProvider
interface.
// using the constructor
var provider = new Iso7064PureSystemProvider(11, 2, false, "0123456789X");
// using the factory
var provider = Iso7064.Factory.Get(11, 2, false, "0123456789X");
There were a couple of small breaking changes between version 1 and version 2 of this library.
The library is now case sensitive, meaning that if you are interpreting inputs from a user you should do some treatment before. This was an intended change to increase library performance while also allowing for any kind of character set composition, even case sensitive.
Reduced the number of directly targeted frameworks but this change should still allow to be used almost everywhere.
- .NET Standard 1.0;
- .NET Standard 2.0;
- .NET Framework 2.0;
- .NET Framework 4.0;
- .NET 5.0;