title: How to generate a verification code/number?
body: <p>I'm working on an application where users have to make a call and type a verification number with the keypad of their phone.</p>
  
  <p>I would like to be able to detect if the number they type is correct or not. The phone system does not have access to a list of valid numbers, but instead, it will validate the number against an algorithm (like a credit card number).</p>
  
  <p>Here are some of the requirements :</p>
  
  <ul>
  <li>It must be difficult to type a valid random code </li>
  <li>It must be difficult to have a valid code if I make a typo (transposition of digits, wrong digit)</li>
  <li>I must have a reasonable number of possible combinations (let's say 1M)</li>
  <li>The code must be as short as possible, to avoid errors from the user</li>
  </ul>
  
  <p>Given these requirements, how would you generate such a number?</p>
  
  <p>EDIT :</p>
  
  <p>@Haaked: The code has to be numerical because the user types it with its phone.</p>
  
  <p>@matt b: On the first step, the code is displayed on a Web page, the second step is to call and type in the code. I don't know the user's phone number.</p>
  
  <p>Followup : I've found several algorithms to <em>check</em> the validity of numbers (See this interesting Google Code project : <a href="http://code.google.com/p/checkdigits/wiki/CheckDigitSystems" rel="nofollow noreferrer">checkDigits</a>).</p>