Hash function

in hash •  4 years ago 

Hā xī hánshù yòu chēng wéi shùzì zhāiyào huò sàn liè hánshù, tā de tèdiǎn shì shūrù yīgè zìfú chuàn, kěyǐ shēngchéng lìngwài yīgè zìfú chuàn, dànshì rúguǒ shūrù bùtóng, shūchū de zìfú chuàn jiù yīdìng bùtóng, érqiě tōngguò shūchū de zìfú chuàn, bùnéng fǎn tuīchū shūrù. Jǔ gè jiǎndān de lìzi, duì 1-100 nèi de shù mó 10, kěyǐ rènwéi shì yī zhǒng hā xī fāngfǎ, bǐrú 98%10=8,66%10=6,98 hé 66 shì shūrù, mó 10 shì hā xī hánshù,8 hé 6 shì shūchū, zài zhège móxíng zhōng, tōngguò 6 hé 8 wúfǎ tuīduàn shūrù shì 66 hé 98, yīnwèi hái kěnéng shì 56 hé 88 děng, dāngrán yīnwèi zhège lìzi bǐjiào jiǎndān, suǒyǐ huì chūxiàn hā xī pèngzhuàng, jí 66 hé 56 de jiéguǒ dōu shì 6, shūchū de jiéguǒ xiāngtóng. Yīgè yōuxiù de hā xī hánshù, kěyǐ zuò dào shūchū yīdìng bùtóng, hā xī pèngzhuàng de gàilǜ jīhū wèi 0. Chángjiàn de hā xī hánshù yǒu hěnduō, bǐrú MD xìliè hé SHA xìliè děng, bǐtè bì cǎiyòng de SHA256 suànfǎ, jí shūrù yīgè zìfú chuàn, shūchū yīgè 256 wèi de èrjìnzhì shù. Xiàmiàn shì chéngxù yùnxíng de jiéguǒ. Tōngguò chéngxù jiéguǒ kěyǐ kàn chū, shūrù de yuán xìnxī bùtóng, dédào de jiéguǒ yě bùtóng (wèile fāngbiàn, jiéguǒ yòng 64 wèi 16 jìn zhì biǎoshì), jíshǐ shì orange duōle yīgè jùhào, yě huì chǎnshēng jiérán bùtóng de jiéguǒ. Tóngshí, tōngguò shūchū de shíliù jìn zhì zìfú chuàn, yě wúfǎ dào tuīchū shūrù. Duìyú bǐtè bì, zhǐyào liǎojiě SHA256 de gōngnéng jí kě, rúguǒ gǎn xìngqù kěyǐ shēnrù liǎojiě SHA256 de jùtǐ suànfǎ. Xūyào SHA256 de C++yuánmǎ liúyán yóuxiāng huò sīxìn.
Show more
523 / 5000
Translation results
Hash function is also called digital digest or hash function. It is characterized by inputting a character string and generating another character string, but if the input is different, the output string must be different, and the output string cannot Reverse the input. For a simple example, the number modulus 10 within 1-100 can be considered as a hash method, such as 98%10=8, 66%10=6, 98 and 66 are inputs, and modulus 10 is the hash function , 8 and 6 are the output. In this model, 6 and 8 cannot infer that the input is 66 and 98, because it may be 56 and 88. Of course, because this example is relatively simple, there will be a hash collision, that is, 66 and The result of 56 is 6, and the output result is the same. An excellent hash function can achieve different outputs, and the probability of hash collision is almost zero. There are many common hash functions, such as MD series and SHA series. Bitcoin uses the SHA256 algorithm, that is, input a string and output a 256-bit binary number. The following is the result of running the program.

image.png

It can be seen from the program results that the input source information is different, and the results obtained are also different (for convenience, the result is expressed in 64-bit hexadecimal), even if the orange has an extra period, it will produce completely different results. At the same time, through the output hexadecimal string, the input cannot be reversed. For Bitcoin, as long as you understand the function of SHA256, if you are interested, you can learn more about the specific algorithm of SHA256. Need SHA256 C++ source message mailbox or private message.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!