You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CHANGELOG.md
+4
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
7
+
## [Unreleased]
8
+
### Added
9
+
- Add `ConvertAlphaNumericToNumeric` method to convert a string containing alphanumeric characters to a string containing only numeric characters (use case: converting an ISIN to a numeric string for Luhn validation).
10
+
7
11
## [1.0.1] - 2024-02-19
8
12
### Fixed
9
13
- Fixed a bug in `Luhn.ComputeLuhnNumber` and `Luhn.ComputeLuhnCheckDigit` methods that sometimes returned an incorrect result.
Copy file name to clipboardexpand all lines: README.md
+53
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
# LuhnDotNet
2
2
An C# implementation of the Luhn algorithm.
3
3
4
+
The Luhn algorithm is a checksum formula used to validate identification numbers like credit card numbers. It works by doubling every second digit from the right, summing all the digits, and checking if the total is a multiple of 10. It's widely used and is specified in ISO/IEC 7812-1.
5
+
4
6
# Build & Test Status Of Default Branch
5
7
<table>
6
8
<thead>
@@ -210,6 +212,57 @@ namespace Example4
210
212
}
211
213
```
212
214
215
+
## Validate ISIN with LuhnDotNet and ConvertAlphaNumericToNumeric
216
+
217
+
The `LuhnDotNet` library can be used in combination with the `ConvertAlphaNumericToNumeric` method to validate an International Securities Identification Number (ISIN). An ISIN uniquely identifies a security, such as stocks, bonds or derivatives. It is a 12-character alphanumeric code.
218
+
219
+
The `ConvertAlphaNumericToNumeric` method is used to convert the alphanumeric ISIN to a numeric string, where each letter in the input string is replaced by its decimal ASCII value minus 55. This numeric string can then be validated using the `Luhn.IsValid` method.
220
+
221
+
Here is an example of how to use these methods to validate an ISIN:
Console.WriteLine($"The ISIN {isin} is valid: {isValid}");
237
+
}
238
+
}
239
+
}
240
+
```
241
+
## Compute ISIN Check Digit with LuhnDotNet and ConvertAlphaNumericToNumeric
242
+
243
+
The `LuhnDotNet` library provides the `ComputeLuhnCheckDigit` method which can be used to compute the check digit of a numeric string according to the Luhn algorithm. When dealing with an International Securities Identification Number (ISIN), which is a 12-character alphanumeric code, we first need to convert the alphanumeric ISIN to a numeric string. This can be achieved using the `ConvertAlphaNumericToNumeric` method.
244
+
245
+
Here is an example of how to compute the check digit of an ISIN:
Console.WriteLine($"The check digit for ISIN {isinWithoutCheckDigit} is: {checkDigit}");
261
+
}
262
+
}
263
+
}
264
+
```
265
+
213
266
# CLI building instructions
214
267
For the following instructions, please make sure that you are connected to the internet. If necessary, NuGet will try to restore the [xUnit](https://xunit.net/) packages.
215
268
## Using dotnet to build for .NET 6, .NET 7, .NET 8 and .NET FX 4.x
0 commit comments