javacheck-digitiban

How can I calculate an IBAN national check digit?


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.


Solution

  • 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.