Question

Following Wikipedia, I’m developing a Java application that calculates and verifies IBANs from various countries. Some BBAN have a national check digit, but I can't find any documentation about how to calculate it. Where I can find the algorithm for "national check digit"? I'm not interested in "iban check digit" but on the country related one.

Was it helpful?

Solution 2

The national check digit is defined in national standards, each country having a different standard. Some countries have one check digit, others have two, yet others don't have any.

Spanish bank account numbers for example have two check digits. The first is based on the 4-digit branch and office codes, and the second one is computed from the 10-digit account number. You can find it documented in any document related to banking IT, for example the ones here, but basically you multiply each digit by a power of 2 mod 11, sum the resulting digits together, and take its remainder when divided by 11. The Wikipedia entry has example code for verifying and computing the check digits.

Other countries use other methods, for example the Luhn algorithm.

OTHER TIPS

When you need to construct/deconstruct the Spanish Iban, spain is a country which has two sets of check digits, calculated in the order below: 45, 91

ES91 2100 0418 4502 0005 1332

Countrycode (2 characters 'ES') Check digits (2 characters) Bank identifier (4 characters) Branch code (4 characters) check digit (2 characters) Account number (10 characters)

Step-by-step guide 1. First, change the ES to its numeric equivalent E=14, S=28 and append this value with 00, so 142800 Now, to get the first set of iban check digits, add account number to the number from step 1: 0200051332142800

  1. Now mod 97 that value, then subtract the remainder from 98. 0200051332142800 mod 97 = 53, 98 - 53 = 45 <- first set of check digits! (smile)

  2. If you end up with one digit, it should be padded with a leading zero.

  3. To get the second iban check digits, append the bank id(2100) to the branch id(0418) then account number, plus first check digits (450200051332)then the value from step 1, in total: 21000418450200051332142800

  4. Again mod 97 that value, 21000418450200051332 mod 97 = 7, 98 -7 = 91 <- second set of check digits (smile)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top