& Lt; hash function under Openssl & gt;

Source: Internet
Author: User

 

Hash function: an irreversible function. Its input can be a byte stream of any length. Its output is of a fixed size. The hash function is used to generate a digest for your file. It is unique.

For example, y = f (x) x indicates that input y indicates that output x is used to calculate y, which is difficult to calculate x by inputting y.

Our common hash functions MD5 and SHA1 are rare.

DM5: Usually 128 bits 16 bytes

Sha1: generally 160 bits, 8 bits, 20 bytes.

 

[Root @ redhat ~] # Md5sum/etc/passwd // There are also commands in linux to calculate the md5 value of the file
C79a0c2c792891374595009e6155435c/etc/passwd


[Root @ redhat ~] # Openssl dgst-md5/etc/passwd
MD5 (/etc/passwd) = c79a0c2c792891374595009e6155435c

 

 

[Root @ redhat ~] # Openssl dgst-sha1/etc/passwd
SHA1 (/etc/passwd) = b4e99419a91a3908e5e5c9c07a0d91c408c1a008

 

 

[Root @ redhat ~] # Sha1sum/etc/passwd
B4e99419a91a3908e5e5c9c07a0d91c408c1a008/etc/passwd

-The hash values provided by the-c parameter to the output are separated:

[Root @ redhat ~] # Openssl dgst-sha1-c/etc/passwd
SHA1 (/etc/passwd) = b4: e9: 94: 19: a9: 1a: 39: 08: e5: e5: c9: c0: 7a: 0d: 91: c4: 08: c1: a0: 08

 

You can also use md5 to verify the integrity of the file. If a byte of the file changes, the hash value changes over the ground.

Generally, MD5 and sha1 values are released on some official websites to prevent software packages from being tampered.

[Root @ redhat opt] # cat txt
Hello world!
[Root @ redhat opt] # md5sum txt
C897d1410af8f2c74fba11b1db1_e9e txt

 

[Root @ redhat opt] # cat txt
Holo world!
[Root @ redhat opt] # md5sum txt
Ada39606d10543a059d139d1debb6a37 txt

 

 

 

 

 

 

 

 

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.