title: two-way keyed encryption/hash algorithm
body: <p>I am no way experienced in this type of thing so I am not even sure of the keywords (hence the title).
  Basically I need a two way function </p>
  
  <pre><code>encrypt(w,x,y) = z
  
  decrypt(z) = w, x, y
  
  Where w = integer 
        x = string (username)
        y = unix timestamp 
  </code></pre>
  
  <p>and z = is an 8 digit number (possibly including letters, spec isn't there yet.) </p>
  
  <p>I would like z to be not easily guessable and easily verifiable. Speed isn't a <em>huge</em> concern, security isn't either. Tracking one-to-one relationship is the main requirement.
  Any resources or direction would be appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Thanks for the answers, learning a lot. So to clarify, 8 characters is the only hard requirement, along with the ability to link W &lt;-> Z. The username (Y) and timestamp (Z) would be considered icing on the cake.</p>
  
  <p>I would like to do this mathematically rather than doing some database looks up, if possible. </p>
  
  <p>If i had to finish this tonight, I could just find a fitting hash algorithm and use a look up table. I am simply trying to expand my understanding of this type of thing and see if I could do it mathematically. </p>