Iban
iban 

所属分类:数学计算
开发工具:C#
文件大小:0KB
下载次数:0
上传日期:2020-03-06 16:05:12
上 传 者sh-1993
说明:  实现Modulo 97算法,以快速验证校验位并具有恒定存储器。
(Implementation of Modulo 97 algorithm to verify check digits fast and with constant memory.)

文件列表:
.editorconfig (10676, 2020-03-06)
Directory.Build.props (621, 2020-03-06)
Iban.sln (2289, 2020-03-06)
perf/ (0, 2020-03-06)
perf/IbanPerf/ (0, 2020-03-06)
perf/IbanPerf/IbanComparison.cs (584, 2020-03-06)
perf/IbanPerf/IbanPerf.cs (1176, 2020-03-06)
perf/IbanPerf/IbanPerf.csproj (363, 2020-03-06)
perf/IbanPerf/Program.cs (541, 2020-03-06)
src/ (0, 2020-03-06)
src/Iban/ (0, 2020-03-06)
src/Iban/Iban.csproj (286, 2020-03-06)
src/Iban/IbanChecksumCalculator.cs (920, 2020-03-06)
src/Iban/IbanDigitizer.cs (2778, 2020-03-06)
src/Iban/InvalidCharacterException.cs (417, 2020-03-06)
test/ (0, 2020-03-06)
test/IbanTests/ (0, 2020-03-06)
test/IbanTests/IbanTests.csproj (907, 2020-03-06)
test/IbanTests/IbanVerifierTest.cs (4820, 2020-03-06)

# IBAN An implementation of the [modulo 97](https://en.wikipedia.org/wiki/International_Bank_Account_Number#Modulo_operation_on_IBAN) algorithm for calculating checksum avoiding use of large integers and allow operation in unsigned integers (< 2^31). Properties of [congruence relations](https://en.wikipedia.org/wiki/Congruence_relation), more specifically [this](https://math.stackexchange.com/questions/1918217/the-mod97-operation-in-iban-validation), give the correctnes of algorithm. ## Background The project started to become acquainted with `Span` to reduce costly string manipulations when calculating the checksum. Along the way I realized that it's possible without any allocations, so the use of `ReadOnlySpan` in this case could just as well be replaced with `char[]`. The iterator `IbanDigitizer` could then strip the `ref` keyword which would allow to implement `IReadOnlyCollection` and make for an even neater API. ## Example Lets take iban number for a Croatian bank and disect the steps. 1. Move last four to the end `CR23015108410023612345 -> 015108410023612345CR23` 1. Replace characters with digits `015108410023612345CR23 -> 015108410023612345122723` 1. Start iteration over nine digit numbers 1. `N = 0151084410, d = N % 97 = 78` 1. `N = _78_0260123, d = N % 97 = 77` 1. `N = _77_451227, d = N % 97 = 25` 1. `N = _25_23, d = N % 97 = 1` 1. If `d == 1` then valid; otherwise invalid. The implemention make us of a specialized "iterator" that perform step 1 and 2 without any allocations.

近期下载者

相关文件


收藏者