当前位置:网站首页>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)
边栏推荐
- [phantom engine UE] the difference between running and starting, and the analysis of common problems
- Ctfshow 2022 Spring Festival welcome (detailed commentary)
- Scheduling system of kubernetes cluster
- After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
- Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
- WeNet:面向工业落地的E2E语音识别工具
- Learning notes 8
- Fuel consumption calculator
- A real day for Beijing programmers!!!!!
- 【FineBI】使用FineBI制作自定义地图过程
猜你喜欢
Looking back on 2021, looking forward to 2022 | a year between CSDN and me
线上故障突突突?如何紧急诊断、排查与恢复
Key review route of probability theory and mathematical statistics examination
CSDN正文自动生成目录
TPG x AIDU | AI leading talent recruitment plan in progress!
Technical tutorial: how to use easydss to push live streaming to qiniu cloud?
WeNet:面向工业落地的E2E语音识别工具
Network layer - forwarding (IP, ARP, DCHP, ICMP, network layer addressing, network address translation)
网络安全-记录web漏洞修复
How to realize real-time audio and video chat function
随机推荐
[phantom engine UE] package error appears! Solutions to findpin errors
Neural networks and deep learning Chapter 4: feedforward neural networks reading questions
电源管理总线 (PMBus)
2022-2028 global and Chinese FPGA prototype system Market Research Report
What are the building energy-saving software
File upload bypass summary (upload labs 21 customs clearance tutorial attached)
[phantom engine UE] only six steps are needed to realize the deployment of ue5 pixel stream and avoid detours! (the principles of 4.26 and 4.27 are similar)
Seven join join queries of MySQL
[moteur illusoire UE] il ne faut que six étapes pour réaliser le déploiement du flux de pixels ue5 et éviter les détours! (4.26 et 4.27 principes similaires)
首席信息官如何利用业务分析构建业务价值?
Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
[thingsboard] how to replace the homepage logo
取余操作是一个哈希函数
函数(易错)
Realize the attention function of the article in the applet
Ctfshow 2022 Spring Festival welcome (detailed commentary)
C26451: arithmetic overflow: use the operator * on a 4-byte value, and then convert the result to an 8-byte value. To avoid overflow, cast the value to wide type before calling the operator * (io.2)
如何进行「小步重构」?
函數(易錯)
Network security - record web vulnerability fixes