I learned about the luhn algorithim from this source: https://en.wikipedia.org/wiki/Luhn_algorithm
I understand the formula. If my understanding is correct, credit card companies will add a checksum number such that it satisfies the mod 10 formula. I have a few questions though and it might have one answer.
Why does this work? Seems pretty random to me to be multiplying each second number and adding it up with the checksum just satisfies this mod 10.
Also, the wiki page says it works for SSN numbers as well. How does that happen? Is there a checksum number for SSN as well?
Does everyone (banks, SSN providers, etc) compose their numbers such that it just has to pass Luhn algorithim?
Yes, exactly. (Well, not everyone - but that's how institutions that use the algorithm do it.) The algorithm works only for numbers chosen so that it works.
In other words, banks and other institutions that use it generate a partial identification number (in whichever way they like), use Luhn's algorithm to compute a check digit, and then append that to the partial number to get the full identification number.
Then the identification number can be verified by using Luhn's algorithm again to see if the check digit is correct.
The US social security numbers do not include a check digit (chosen by Luhn's algorithm or in any other way) but the Social Insurance Numbers issued by Canada do, as well as several others listed in the article.
In some ways this algorithm is very arbitrary, but the goal of all checksum algorithms is to make sure that when common errors are made in writing down the number, the checksum will become invalid.
The Wikipedia algorithm mentions that single-digit errors, and almost all transpositions of adjacent digits, are detected by Luhn's algorithm.