在CentOS系统中使用sha256sum来校验下载的文件的方法

哈希值用作表示大量数据的固定大小的唯一值。两组数据的哈希值仅在相应数据也匹配时才应当匹配。数据的少量更改会在哈希值中产生不可预知的大量更改。SHA256 算法的哈希值大小为 256 位。

The program sha256sum is designed to verify data integrity using the SHA-256 (SHA-2 family with a digest length of 256 bits). SHA-256 hashes used properly can confirm both file integrity and authenticity.

sha256sum校验步骤:

[root@localhost sha256sum]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.5 (Final)
Release:        6.5
Codename:       Final

一、打开终端,并进入目标目录,也就是存放Fedora-Workstation-25-1.3-x86_64-CHECKSUM和Fedora-Workstation-Live-x86_64-25-1.3.iso的目录。

[root@localhost sha256sum]# cd sha256sum

再用命令ls查看一下当前目录的文件信息。

[root@localhost sha256sum]# ls -l

输出如下:

[root@localhost sha256sum]# ls -l
total 1406984
-rw-r--r-- 1 root root       1089 Nov 18  2016 Fedora-Workstation-25-1.3-x86_64-CHECKSUM
-rw-r--r-- 1 root root 1440743424 Nov 16  2016 Fedora-Workstation-Live-x86_64-25-1.3.iso

二、用sha256sum校验文件Fedora-Workstation-Live-x86_64-25-1.3.iso。

[root@localhost sha256sum]# sha256sum Fedora-Workstation-Live-x86_64-25-1.3.iso

输出如下:

[root@localhost sha256sum]# sha256sum Fedora-Workstation-Live-x86_64-25-1.3.iso
818017f42a2741cfaf20e94aecf6a63d1b995abfdaff5917df7218d0d89976a7  Fedora-Workstation-Live-x86_64-25-1.3.iso

三、和CHECKSUM对比,看看输出结果是不是OK。

输入如下:

[root@localhost sha256sum]# sha256sum -c Fedora-Workstation-25-1.3-x86_64-CHECKSUM

输出如下:

[root@localhost sha256sum]# sha256sum -c Fedora-Workstation-25-1.3-x86_64-CHECKSUM
Fedora-Workstation-Live-x86_64-25-1.3.iso: OK

经检验下载的Fedora-Workstation-Live-x86_64-25-1.3.iso完整无误,OK!!!

Leave a Reply

Your email address will not be published. Required fields are marked *