linux - hash algorithm
作者:互联网
A Hashing Algorithm is a mathematical formula that takes a Message of arbitrary length as input and produces as output a representational sample of the original data.
For instance, a rudimentary example of a hashing algorithm is simply adding up all the letter values of a particular message. (A=1, B=2, C=3, etc…):
The result of a hashing algorithm is called a message Digest (or sometimes Checksum, or Fingerprint). The result of our example hashing on the original message of hello
was 52
. If someone were to change our original message and process it through the same hashing algorithm, the result would be different:
By comparing the message digests of each calculation, it is easy to determine that our message has changed.
Obviously, the Hashing algorithm used in the example is full of flaws. There are many words that when processed through the example algorithm that might result in the same Digest. Had the original Message been changed to cellt
, the resulting digest would still be 52, and we would be unaware that the original Message had been altered.
Hashing Demonstration with Linux
The standard Linux terminal typically comes with at least two of the Hashing Algorithms mentioned above: MD5 and SHA1. You can use the echo
command along with md5sum
or sha1sum
to run either algorithm on a string of text:
标签:hash,algorithm,example,result,linux,message,original,Hashing 来源: https://www.cnblogs.com/xman888/p/15571476.html