How to get the IBAN of a Brazilian bank account

1 Step 1: call the bank

and ask the IBAN number

2 Step 2: understand and verify it

Suppose the given you the number of the form:


We observe that:
  • It should start with BR

  • The pq is the checksum (which we will now be verifying)

  • The xxxxxxxx is the bank code (which is 00000000 for Banco do Brasil)

  • The yyyyy is the numeric code of the branch (agência)

  • zzzzzzzzzz is somehow derived from your account number (with some information loss???)

  • C probably means checking, and 1 that you are the primary owner

Now compute:
  1. U = xxxxxxxxyyyyy mod 97

  2. V = Uzzzzzzzzzz mod 97

  3. W = V1211127pq mod 97

(Remember to use Long in such calculations, rather than Integer) In the computation of W, 12 is the numerical value of letter C, and 11 and 27 are the numerical values of the letters B and R in BR. Notice that we moved BRpq from the start to the end!

You should get 1