Experimental hash function based on the non-reversible Cellular Automata Game of Life
Implementation of Game Of Life here!
-
hash_length: the length of the final hash (default:
512), if0: get the full size hash -
iter: number of the Game of Life iterations applied to the initial grid (default:
5) -
grid_size: size of the grid used to apply Game of Life iterations (default:
128) -
print_grid: if
True: print the initial grid and final grid to terminal (default:False)
-
this hash function do not use any external library apart from numpy for the generation of the random grid
-
the Game of Life is non-reversible (there are multiple pre-configurations for every grid configuration)
-
change the mode variable to switch from the two modes:
-
hash mode: generate the hash text
-
bias_test mode: test the bias of the hexadecimal values of the hash (is possible to change the n_iteration variable to test more hashes in a row)
-
-
generate the key converting the input string into a list of the input characters econded in utf-8
-
create the random grid using the key as seed
-
execute the non-reversible Game of Life iterations on the grid
-
linearize the matrix in a string of bits
-
remove any string of 5 consecutive zeros (
00000) string from the string of bits to decrease the0/1bias -
shuffle the string of bits
-
convert groups of 4 binary bits into hexadecimal values
-
shuffle the string of hexadecimal values
-
trim the string of hexadecimal values to the desired size
-
return the final hash
The CA-hash function has some bias, caused by the bias in 0's and 1's in Game Of Life.
To decrease this bias, every string of 5 consecutive zeros (00000) will be removed from the linearized matrix.
Input:
"test"Hash length:
512Number of Game Of Life iterations:
5Grid size:
128
Input:
"test"Hash length:
1024Number of Game Of Life iterations:
5Grid size:
128
Input:
Numerical range from 0 to 99Hash length:
512Number of Game Of Life iterations:
5Grid size:
128
Input:
Numerical range from 0 to 99Hash length:
1024Number of Game Of Life iterations:
5Grid size:
128