Note, this is not about using libraries or any specific programming language. I just want to understand the following concept, from Wikipedia, Validating the IBAN:
Example (fictitious United Kingdom bank, sort code 12-34-56, account number 98765432):
IBAN:
GB82 WEST 1234 5698 7654 32
Rearrange:
W E S T12345698765432 G B82
Convert to integer:
3214282912345698765432161182
Compute remainder:
3214282912345698765432161182 mod 97 = 1
The bold step is causing me headache. I'm assuming the IBAN is alphanumeric, i.e., Base-36 encoded (10 numbers, 26 letters).
Now, when I convert the base-36 to base-10 (this is how I understand this step), my result is way off. Here, for example, in Ruby:
$ irb
irb(main):001:0> "WEST12345698765432GB82".to_i(36)
=> 15597194993925618867946544653683410
Now, please, someone enlighten me, what is really meant by convert to integer?
Oh! The formatting on Wikipedia gave me a hint: It's not a single, whole, big number but each character has to be converted on its own:
Result:
Note, the
W
is the 32th integer in Base-36:And so on.