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.
-
Here perhaps? [the first google result for "how to calculate iban check digit"](http://www.ibancalculator.com/calculation.html) – Simon Forsberg Nov 09 '13 at 18:15
-
4Well, i'm talking about "national check digit", not the "iban check digit". – Tostis Nov 09 '13 at 18:19
2 Answers
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
Now mod 97 that value, then subtract the remainder from 98. 0200051332142800 mod 97 = 53, 98 - 53 = 45 <- first set of check digits! (smile)
If you end up with one digit, it should be padded with a leading zero.
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
Again mod 97 that value, 21000418450200051332 mod 97 = 7, 98 -7 = 91 <- second set of check digits (smile)

- 99
- 1
- 4
-
1
-
You cant get the numeric value with a function of java, for example, Character.getNumericValue('a') -> 10 – Joe Feb 12 '18 at 07:22
-
-
This answer calculates the IBAN check digit, not the national BRAN check digit. The BRAN is a component of the overall IBAN and the question relates specifically to this component whose structure is defined by national standards and is not within the purview of the IBAN standard. – Terry Burton Dec 25 '20 at 08:59
-
This response is incorrect for the intended question. It explains how the IBAN check digits next to the country code are calculated but the algorithm is different for the local country. The Spanish check digit is calculated completely different. You can find explanations here: In spanish: https://www.openbank.es/open-news/digito-control-cuenta-bancaria/ In English: https://docs.oracle.com/cd/E26401_01/doc.122/e48900/T359831T498954.htm – Eduo Dec 15 '22 at 11:54
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.

- 108,737
- 14
- 143
- 193
-
Thanks for your answer but i've already found docs about Italian and Spanish national check digit. Maybe i'll search documentation on institution sites like ABI (IT) or AEB (ES), but i have to find these regulation for each country first. – Tostis Nov 10 '13 at 09:32
-
-