Center square method

from Wikipedia, the free encyclopedia

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

It's a simple method that uses a seed number to square it. The middle digits of the square are taken as the first random number . In the next iteration , the previous random number is squared and the middle digits make up the next random number, and so on, until that row of random numbers stops printing.

The starting number can e.g. For example, the time or the number of milliseconds that have passed since the computer started. Donald Knuth showed that according to this method, the random numbers repeat themselves after 142 numbers (when using 20-bit numbers).

In hashing, the seed count is the key value and only one iteration is necessary.

One advantage is the simple implementation of the method. The disadvantages are the very high computing effort, the very short period length and the frequent crash to the number zero. The method is not suitable for use as a hash function, since the frequency of collisions is greater with certain common key value distributions than with other, simpler hashing methods (see e.g. multiplicative method ).

This method has only historical significance.

example

After each iteration, the two middle digits are selected:

62 62 = 3 84 4
84 84 = 7 05 6
5 5 = 0 02 5
2 2 = 0 00 4
0 0 = 0 00 0
...

literature