当前位置:网站首页>The remainder operation is a hash function
The remainder operation is a hash function
2022-07-05 04:28:00 【Blue dye k9z】
Hash
Hashes are sometimes translated as hashes .
It is to input any length , Through the hash algorithm , Compressed to a fixed length of output .
- If you want to read and write quickly 100 Ten thousand data records , To achieve high-speed access , But due to the limitation of conditions , We are not able to accommodate 100 Continuous address space of 10000 records , What should I do .
- See if the system can provide several smaller continuous spaces , And each space can store a certain number of records .
- For example, we found 100 A smaller continuous space . in other words , These spaces are separated from each other , But the interior is continuous , And enough to hold 1 Ten thousand records are stored continuously , Then we can use the remainder and congruence theorem to design a hash function , And implement the structure of hash table .

- Suppose there are two records , Their record labels are 1 and 101.
- We put these models 100 Then the remainder is 1 Of , Store in No 1 In a free space .
- And so on , Set the remainder to 2 Of 2、102、202 etc. , Store in No 2 Two free spaces .
- such , We can change according to the fast number of the remainder , Group data , And store them in different address spaces .
- The remainder operation itself is very simple , Therefore, there is little increase in addressing time .

In order to increase the randomness of data hash , You can add a large random number to the formula MAX
Under the action of the new calculation formula , Will be allocated to different available space
Used MAX After this random number , Records allocated to the same space are more “ Random ”, It is more suitable for application scenarios that need to reshuffle the data , Such as encryption algorithm 、MapReduce Data distribution in 、 High speed query and location of records, etc .
encryption
Suppose you want to encrypt a set of three digits , Then set such an encryption rule :
- Start with each three digit number 、 Tens and hundreds , Add a large random number .
- Then divide the number on each by 7, Replace the original... With the remainder 、 Ten 、 Hundreds of digits .
- Finally, the first and third bits are exchanged .
This is a basic encryption transformation process .
If say , We need to encrypt 625, Random number selection 590127.
Na Bai 、 Ten 、 Add this random number to each bit , It becomes 590133 590129 590132, Divide the three by 7 Find the remainder and get 5 1 4.
The final figure is 415.
If the encryption person knows the encryption rules , Then we can calculate that the original data is 625.
( Tips :590127%7=6)
边栏推荐
- How to get the first few pieces of data of each group gracefully
- 2022-2028 global and Chinese virtual data storage Market Research Report
- 学习MVVM笔记(一)
- A應用喚醒B應該快速方法
- 【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
- About the project error reporting solution of mpaas Pb access mode adapting to 64 bit CPU architecture
- Threejs rendering obj+mtl model source code, 3D factory model
- A application wakes up B should be a fast method
- 假设检验——《概率论与数理统计》第八章学习笔记
- 快手、抖音、视频号交战内容付费
猜你喜欢

Sequence diagram of single sign on Certification Center

Rome chain analysis

【虚幻引擎UE】实现测绘三脚架展开动画制作

Network layer - forwarding (IP, ARP, DCHP, ICMP, network layer addressing, network address translation)

Official announcement! The third cloud native programming challenge is officially launched!

Raki's notes on reading paper: soft gazetteers for low resource named entity recognition

【UNIAPP】系统热更新实现思路

【thingsboard】替换首页logo的方法

2022-2028 global and Chinese equipment as a Service Market Research Report

Threejs Internet of things, 3D visualization of farms (II)
随机推荐
File upload bypass summary (upload labs 21 customs clearance tutorial attached)
Looking back on 2021, looking forward to 2022 | a year between CSDN and me
托管式服务网络:云原生时代的应用体系架构进化
Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
Network security - record web vulnerability fixes
CSDN正文自动生成目录
概率论与数理统计考试重点复习路线
学习MVVM笔记(一)
Cookie learning diary 1
[illusory engine UE] method to realize close-range rotation of operating objects under fuzzy background and pit recording
Number of possible stack order types of stack order with length n
2022-2028 global and Chinese FPGA prototype system Market Research Report
Neural network and deep learning Chapter 1: introduction reading questions
【UNIAPP】系统热更新实现思路
kubernetes集群之调度系统
Longyuan war "epidemic" 2021 network security competition web easyjaba
Uncover the seven quirky brain circuits necessary for technology leaders
PHP reads the INI file and writes the modified content
直播預告 | 容器服務 ACK 彈性預測最佳實踐
Convert Boolean to integer value PHP - Convert Boolean to integer value PHP