Do you know why the Luhn mod N algoritm in order to create the check digit performs a sum by doubling the value of each even placed char instead of perfoming a simple sum of all chars?
In pseudo-code words:
given:
var s = "some string i want to create check digit";
do you know why Luhn mod N does basically this:
for(i from s.length-1 to 0)
if(i is even)
checkdigit += chr2int(s[i]) * 2;
else
checkdigit += chr2int(s[i]);
instead of simply doing a sum
for(i from s.length-1 to 0)
checkdigit += chr2int(s[i]);
they can still both terminate with a mod
operation to make the checkdigit fit into one char
return int2chr( chr2int('a') + (checkdigit mod 25) );
As a side note to this question, to whom it may be interested in a graphic representation of the Luhn algorithm that makes it even more simple to understand:
Actually this one is the original Luhn algorithm that does not even needs to use MOD function.