Middle-square method

The mid- square method ( also Mid- square method or mean-square method called, from the English middle square method, or mid -square method) was founded in 1946 by John von Neumann presented as one of the first random number generators. Later, this function has been used as a hash function.

It is a simple method in which from a starting number, the square is formed. The middle digits of the square be taken as a first random number. In the next iteration, the previous random number is squared, and the middle digits give the next random number and so on until the output of this random number sequence is terminated.

The starting number can be, eg, the time or the number of milliseconds that have elapsed since the start of the computer. Donald Knuth showed that repeat themselves according to this method, the random numbers by 142 number (when using 20 -bit numbers ).

Hashing is the initial number of the key value, and there is only one iteration is necessary.

One advantage is the ease of implementation of the method. The disadvantages are the high computational effort, the very short period length and the frequent crashes to the number zero. For use as a hash function, the method is not suitable because the collision frequency is higher in certain conventional key-value distributions than other simpler hashing method (see, for example, Multiplicative method).

This method only has historical significance.

Example

After each iteration, the middle two digits are each selected:

62 · 62 = 3844 84 · 84 = 7056 5 x 5 = 0025 2 · 2 = 0004 0 · 0 = 0000 ...

570702
de