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
Merge pull request #48 from shinji-san/release-v1.1.0
Release v1.1.0
Added:
- 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).
Resolves: #48
Copy file name to clipboardexpand all lines: CHANGELOG.md
+6-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,11 @@ 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
-
## [1.0.1] - 2024-02-19
7
+
## [1.1.0] - 2024-03-30
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
+
11
+
## [1.0.1] - 2024-03-19
8
12
### Fixed
9
13
- Fixed a bug in `Luhn.ComputeLuhnNumber` and `Luhn.ComputeLuhnCheckDigit` methods that sometimes returned an incorrect result.
10
14
@@ -42,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Copy file name to clipboardexpand all lines: README.md
+114-11
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>
@@ -61,9 +63,9 @@ An C# implementation of the Luhn algorithm.
## 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
+
266
+
## Compute credit card number with LuhnDotNet
267
+
The `LuhnDotNet` library can be used to compute the check digit of a credit card number. The check digit is the last digit of the credit card number, which is used to validate the number according to the Luhn algorithm.
Console.WriteLine($"The check digit for credit card number {creditCardNumberWithoutCheckDigit} is: {checkDigit}");
283
+
}
284
+
}
285
+
}
286
+
```
287
+
288
+
## Validate credit card number with LuhnDotNet
289
+
The `LuhnDotNet` library can be used to validate a credit card number according to the Luhn algorithm. The `IsValid` method returns `true` if the credit card number is valid, and `false` otherwise.
Console.WriteLine($"The credit card number {creditCardNumber} is valid: {isValid}");
305
+
}
306
+
}
307
+
}
308
+
```
309
+
213
310
# CLI building instructions
214
311
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
312
## Using dotnet to build for .NET 6, .NET 7, .NET 8 and .NET FX 4.x
@@ -219,30 +316,36 @@ Use one of the following solutions with `dotnet` to build [LuhnDotNet](#luhndotn
0 commit comments