Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This seems to be a case for <a href="http://en.wikipedia.org/wiki/Key_derivation_function" rel="nofollow noreferrer">key derivation functions</a>. Have a look at <a href="http://en.wikipedia.org/wiki/PBKDF2" rel="nofollow noreferrer">PBKDF2</a>.</p> <p>Just using cryptographic hash functions (like the SHA family) will give you the desired distribution, but for very limited input spaces (like credit card numbers) they can be easily attacked using brute force because this hash algorithms are usually designed to be as fast as possible.</p> <p><strong>UPDATE</strong></p> <p>Okay, security is no concern for your task. Because you have already a numerical input, you could just use this (account) number modulo your hash table size. If you process it as string, you might indeed encounter a bad distribution, because the ten digits form only a small subset of all possible characters.</p> <p>Another problem is probably that the numbers form big clusters of assigned (account) numbers with large regions of unassigned numbers between them. In this case I would suggest to try highly non-linear hash function to spread this clusters. And this brings us back to cryptographic hash functions. Maybe good old MD5. Just split the 128 bit hash in four groups of 32 bits, combine them using XOR, and interpret the result as a 32 bit integer.</p> <p>While not directly related, you may also have a look at <a href="http://en.wikipedia.org/wiki/Benford&#39;s_law" rel="nofollow noreferrer">Benford's law</a> - it provides some insight why numbers are usually not evenly distributed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload