title: Two-way hashing of fixed range numbers
body: <p>I need to create a function which takes a single integer as argument in the range <code>0-N</code> and returns a seemingly random number in the same range.</p>
  
  <p>Each input number should always have exactly one output and it should always be the same.</p>
  
  <p>Such a function would produce something like this:</p>
  
  <pre><code>f(1) = 4
  f(2) = 1
  f(3) = 5
  f(4) = 2
  f(5) = 3
  </code></pre>
  
  <p>I believe this could be accomplished by some kind of a hashing algorithm? I don't need anything complex, just not something too simple like <code>f(1) = 2</code>, <code>f(2) = 3</code> etc.</p>
  
  <p>The biggest issue is that I need this to be reversible. E.g. the above table should be true left-to-right as well as right-to-left, using a different function for the right-to-left conversion is fine.</p>
  
  <p>I know the easiest way is to create an array, shuffle it and just store the relations in a db or something, but as I need <code>N</code> to be quite large I'd like to avoid this if possible.</p>
  
  <p><strong>Edit:</strong> For my particular case <code>N</code> is a specific number, it's exactly 16777216 (64^4).</p>