Take the 2-minute tour ×  I need to generate a verification code
and send it to a customer, so that the customer can then provide
the code later and I validate it. I want to be able to do this
without storing the verification codes in a database, i.e., the
codes should be self-containted.  How can I generate the code
and prevent the customer from just guessing what a valid code
is? Obviously, I can't completely rule out a lucky guess, but I
want the probability of such an event to be reasonably small,
while keeping the code length small. A code may contain digits
and letters.  For example, a very basic verification code would
be like this: randomly generate the number 1122. Now, compute
the verification code 11226 ( 1122 and append its checksum
6=1+1+2+2). So, if the customer sends back 11226 back I would be
able to validate it, but of course this is too easy to tamper
with. Is there a method to generate such codes?  EDIT: The
problem is that the system which sends the verification code and
the system where t