当前位置:网站首页>Improvement of hash function based on life game
Improvement of hash function based on life game
2022-06-12 07:49:00 【FishPotatoChen】
0 lead said
Hash The function is in 20 century 50 Technology introduced in the s , It maps an arbitrary length message to a fixed length message digest .Hash Function was first used to detect random errors due to noise in message transmission , Later, it was mainly used to detect human errors or fabricated messages in message transmission . be based on Hash The application of function message authentication is developing rapidly , Widely used, including message authentication 、 Password check 、 software protection 、 Construction of encryption algorithms and other fields .
The game of life is English mathematician John · Horton · Conway is in 1970 Cellular automata invented in , Each grid in the game of life follows simple rules , The following rules :
1. The state of each cell is determined by the last state of the cell and its surrounding eight cells ;
2. If a cell has 3 One cell for life , The cell is living , That is, if the cell was originally dead , Turn to life , If it was a living , Keep the same ;
3. If a cell has 2 One cell for life , Then the state of life and death of the cell remains the same ;
4. In other cases , The cell is dead , That is to say, if the cell was originally living , Turn to death , If it was death , Keep the same .
1 Based on the game of life hash function
The game of life has simple rules , Interaction between each cell unit , Showing extremely complex forms . The final evolution of the game depends on the initial conditions and rules of the game .
Use the game of life to test a piece of data hash operation , The algorithm is described as follows :
① Select canvas size ;
② Set the rules ;
③ Solve operations beyond the boundary , It can be calculated according to its corresponding boundary , For example, the cells on the left boundary , The operation of determining life and death is carried out by the surrounding cells and their corresponding cells on the boundary , You can also give up , Or other rules ;
④ Determine the number of cycles ;
⑤ Make sure you want to select hash Number of digits of the value ;
⑥ Processing and converting data ;
⑦ obtain hash value .
Its original rules cannot be used here , Because the original rules will soon lose all the data , So here , The rules need to be changed .
2 About the relevant calculation of the algorithm
One way :
Here, take the original rule as an example to calculate , A living lattice , There are two situations , First , This lattice makes a living , And the last status of the surrounding grid is 2 raw 6 die , So there is 28 In this case ; perhaps , The last status of the grid around this grid is 3 raw 5 die , So there is 56 In this case .
A lattice for death , There are two situations , First , This grid is dead , And the last status of the surrounding grid is 2 raw 6 die , So there is 28 In this case ; perhaps , The last status of the grid around this grid is not 3 raw 5 Dead and the last state of this grid is alive , So there is 172 In this case ; also , The last status of this grid is dead , And the last status of the surrounding grid is 2 raw 6 die , So there is 28 In this case .
Because the last state of this grid is lost , And this is just a grid , Therefore, the absolute unidirectionality is guaranteed .
3 Performance analysis and algorithm simulation
Experimental analysis of the above algorithm :
① take 200 That's ok 300 Column canvas ;
② Take the rules as the improvement of the original life game rules , There is 2 A or 4 Make a living in a grid , Then this lattice will not change , There is 3 Make a living in a grid , Then this grid makes a living , The rest of the cases are dead ;
③ Solve operations beyond the boundary , Operation according to its corresponding boundary , Turn the canvas into a closed loop ;
④ Then take a set of data , Here we take random numbers , One 30 That's ok 30 Columns of the matrix , For intuitive performance , Convert binary to 1 Take black ,0 Take white , The display is shown in the picture figure1;
figure1
⑤ Determine the number of cycles , Here is to show the stable results , Take a larger number of times , take 600 Time ;
⑥ Make sure you want to select hash Number of digits of the value , As a demonstration , Take the whole canvas here ;
function
⑦ obtain hash value , The visual display is shown in the figure figure2.
figure2
4 Statistical analysis of chaos and diffusion properties
The second row and the second column of the data in the above example are divided into 1 Change it to 0, The visual display is shown in the figure figure3
figure3
You can see that the color of the second row and the second column changes to white , Proceed again hash, obtain hash value , The visual diagram is shown in the figure figure4.
figure4
To hide the redundancy of plaintext information ,Shannon Put forward the concept of chaos and diffusion , That is, encryption system requires full and uniform use of ciphertext space . Try to make clear text correspondence Hash Values are not relevant , For binary representation of information , Each bit can only be 0 or 1 Two possible , So ideal Hash The diffusion effect of is caused by the slight change of initial value Hash value 50% Transformation of . From the above Hash The experiment shows that , The data changes by one bit , The degree of change reaches 48.735%, near 50%, It has good chaos and diffusion .
4 improvement
You can simply take a small piece of the entire canvas as hash Worth the end result , You can also change two dimensions into three dimensions or higher . The size of the input information can be determined by the size of the canvas , This will hash Function becomes a flexible function , In order to meet the needs of different occasions .
5 Conclusion
By changing the rules of the game of life , Play life with hash Function combination , Through the image to better show hash The process of .
边栏推荐
- Personalized federated learning with exact stochastic gradient descent
- 20220524 深度学习技术点
- @Datetimeformat @jsonformat differences
- Voice assistant - those classification models used in the assistant
- 谋新局、促发展,桂林绿色数字经济的头雁效应
- 石油储运生产 2D 可视化,组态应用赋能工业智慧发展
- Arrangement of statistical learning knowledge points -- maximum likelihood estimation (MLE) and maximum a posteriori probability (map)
- Numerical calculation method chapter6 Iterative method for solving linear equations
- Numerical calculation method chapter5 Direct method for solving linear equations
- R语言使用caTools包的sample.split函数将机器学习数据集划分为训练集和测试集
猜你喜欢

謀新局、促發展,桂林綠色數字經濟的頭雁效應

MySQL index (easy to handle in one article)

Summary of machine learning + pattern recognition learning (V) -- Integrated Learning
![[yolo-v5 learning notes]](/img/f8/713210cafd7b750df540acbe03fd29.jpg)
[yolo-v5 learning notes]

Topic 1 Single_ Cell_ analysis(4)

Arrangement of statistical learning knowledge points -- maximum likelihood estimation (MLE) and maximum a posteriori probability (map)

电脑连接上WiFi但是上不了网

Interview computer network - transport layer

vscode 1.68变化与关注点(整理导入语句/实验性新命令中心等)

Dynamic simulation method of security class using Matlab based Matpower toolbox
随机推荐
Federated reconnaissance: efficient, distributed, class incremental learning paper reading + code analysis
Voice assistant - potential skills and uncalled call technique mining
Topic 1 Single_ Cell_ analysis(2)
2、 Eight, ten and hexadecimal conversion
LeetCode笔记:Weekly Contest 295
Kalman filter encapsulation function
Leetcode34. find the first and last positions of elements in a sorted array
Generalized semantic recognition based on semantic similarity
VS2019 MFC IP Address Control 控件继承CIPAddressCtrl类重绘
2021.10.31-11.1 scientific research log
石油储运生产 2D 可视化,组态应用赋能工业智慧发展
初步认知Next.js中ISR/RSC/Edge Runtime/Streaming等新概念
LeetCode笔记:Weekly Contest 296
Hongmeng OS first training
MSE (mean square error) calculation package function
How to stop MySQL service under Linux
10 lessons from the recommended system
Xshell installation
Leetcode notes: Weekly contest 296
Exposure compensation, white increase and black decrease theory