Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Belgium IBAN incorrect checksum #2165 #2175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xeirzo
Copy link

@xeirzo xeirzo commented Feb 11, 2025

Signed-off-by: xeirzo <>

What does this change

This change adds a fix to the BBAN, IBAN checksum generation and validation by changing the generation formula, and rewriting the tests to be more precise.

What was wrong

According to https://www.ibancalculator.com there is an issue with both the IBAN and BBAN checksum generation,

BBAN

  • calculation was done using : 97 - (account_number) % 97.
  • instead of : (account_number % 97) or 97 if previous calculation returns 0.

The calculator site verifies to true when using the later version,
moreover in https://www.ecbs.org/iban/belgium-bank-account-number.html there's an example of a valid BBAN that supports my claim.
Valid BBAN : 539007547034.
5390075470 is the account number and 34 is the resulting checksum,
if we use 5390075470 % 97 we get 34.
If we use 97 - (5390075470 % 97) we get 63 which is not the example given above (539007547034),
which further proves the point.

IBAN:

The wiki elaborates on how to generate a checksum for the IBAN under Processing -> Algorithms.
in the previous version the mod calculation was done before converting chars to numbers and rearranging the IBAN which is incorrect, this version fixes this.
In addition the test for the IBAN didn't check if the resulting IBAN checksum is valid and only checked if the country code was added, and overall string structure.

How this fixes it

By changing the method of calculation of the IBAN/BBAN checksums and making the tests cover the checksum generation it fixes the problem.

fixes #2165 which emerged from #2142

Checklist

  • I have read the documentation about CONTRIBUTING
  • I have read the documentation about Coding style
  • I have run make lint

Copy link
Collaborator

@fcurella fcurella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Belgium IBAN incorrect checksum
2 participants