ISO 7064 is a standard promulgated by the International Standards Organization that defines algorithms for calculating check digit characters. The checks should be applicable to alphanumeric strings and should be able to detect all single substitution errors, all or nearly all single local transposition errors, all or nearly all circular shift errors, a high proportion of double substitution errors, a high proportion of all other errors.

It is used in some other ISO standards like IBAN, ISTC, ISNI, LEI. In our everyday life we see it in IBAN, but also we can use it many other systems like identification systems (Croatia and China) and other.

So, I personally needed a library to verify and calculate those check digits in Go. After some research I’ve found out that there are a few libraries like digitorus/iso7064 and almerlucke/go-iban, but they are hardcoded for MOD97–10 (used in IBAN) and that is all. Other algorithms like MOD11–2, MOD37–2, MOD661–26 and MOD1271–36 are not implemented in them. So, I’ve decided to create a library which will fill my needs. First of all, implementation of all algorithms listed above.



Then there is a structure called BaseCalculator, which implements methods from Calculator interface implements ISO7064 base algorithm. It’s code is:

As you can see BaseCalculator structure has fields called Modulus, Radix, Charset and IsDouble. So, various combinations of these fields allow us to create different algorithms described in ISO7064 like MOD11–2, MOD37–2, MOD97–10, MOD661–26, MOD1271–36, but also use any other combination to create another nonstandard algorithm based on ISO7064 base algorithm. There is an example how to create BaseCalculator for ISO7064 MOD97–10:

So, by analogy, we can create BaseCalculators for other algorithms.

But also we should implement IBANCalculator which will do IBAN specific steps like rearranging and letter to integer conversion. There is it’s code:

It uses BaseController with MOD97–10 configuration to compute check digit characters and also rearranges and converts letter to integers in IBAN before the calculation.


Just a 16 year old boy, who codes whatever he wants.