How the MOD-97 Algorithm Validates IBANs and Catches Typos Before Transfers
Every IBAN contains two check digits immediately after the country code, computed using the MOD-97 algorithm (ISO 7064), which allows banks and software to detect transcription errors before a payment is processed. To validate an IBAN, the number is normalized, rotated so the country code and check digits move to the end, letters are converted to two-digit numbers, and the resulting large integer is divided by 97. A remainder of exactly 1 confirms the IBAN is internally consistent; any other result indicates an error in the number. Importantly, passing this check only verifies the number's internal integrity and correct length — it does not confirm that the bank account actually exists, which requires a separate directory lookup. Developers can implement the validation in Python using arbitrary-precision integers, with an added per-country length check recommended for production use.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in