algorithmibanbban

How to transform a BBAN account to an IBAN account


The question is in the title, the BBAN is a Belgian Bank Account Number.

I don't need the code for it I know it is some simple modulo addition but I don't know the exact rules to do it(algorithm).

I only found validation rules no transformation/conversion rules.

Thanks


Solution

  • Here is my python version if the algorithm provided in the link of antiheadshot

    def get_IBAN(bban):   #bban is a string
        bb_ck = int(bban[-2:])
        dummy = bb_ck * 100000000 + bb_ck * 1000000 + 111400
        ib_ck = 98 - (dummy % 97)
        return "BE%s%s" % (ib_ck, bban)
    

    the algorithm from https://thebasementgeek.wordpress.com/2011/03/01/calculate-iban-numbers-from-a-belgian-bank-account-number/

    1. Drop all non-alphanumerical characters from a bank account number
    2. Retrieve the last two digits (old bank account number check digit)
    3. 98-(mod97(####111400) where ## stands for the check digits, which need to be appended twice.
    4. create IBAN number by appending country code, the calculated check digits from step 3 and the the old bank account number, in that order