Seriously:
I think I might get into trouble by posting a direct link, but there are loads of websites if you search google for the right words that will 'explain' (but not show) the key process.
It's similar to the Visa Mod 10 calculations that create valid credit card numbers and such.
Hard to understand at first, but once you sit down with pen and paper and go through it in simple steps it starts to make sense (but not complete sense!)