zoukankan      html  css  js  c++  java
  • 文件一致性校验(MD5,SHA1,GPG)


    一 为何要进行文件一致性校验?

    为了确保你得到的文件是正确的版本,而没有被注入病毒和木马程序。例如我们经常在网上下载软件,而这些软件已经被注入了一些广告和病毒等,如果不进行文件与原始发布商的一致性校验的话,可能会给我们带来一定的损失。

    二 文件一致性校验原理
    要进行文件的一致性校验,我们不可能像文本文件比较那样,将两个文件放到一起对比,因为很多的时候文件很大。目前最理想的办法就是,是通过加密算法,对文件生成对应的值,通过生成的值与发布商提供的值比较来确认两个文件是否一致。

    MD5和SHA1就是目前使用最为广泛的良种加密算法。这两种算法都是基于MD4,但又略有不同。一般来说,SHA1计算速度比较慢,但抗穷举行能也更好。

    另外,SHA1是美国国家标准局颁布的标准加密算法。因此,在微软发布的Windows操作系统等光盘中,提供的就是sha1校验码。Google Code社区使用也是sha1验证码。

    比较常用的还有GPG。

    三 文件一致性校验工具

    1) MD5+SHA1

    * SUM, LINUX命令,用来获得文件的checksum和blocksize,常被用来检测文件是否被修改过。

    * cksum, a Unix command that generates both a 32-bit CRC and a byte count for any given input file.
    * md5sum, a Unix command that generates a MD5 sum (commonly used to verify .iso files)
    * jdigest, a Java GUI tool that generates and checks MD5 and SHA sums
    * Unix programs called md5/sha1 or md5sum/sha1sum are included in many unix distributions.
    * sum is also available as part of GNU Textutils.
    * md5, a command line utility usable on either Unix or MS-DOS/Windows, which generates and verifies message digests (digital signatures) using the MD5 algorithm. This program can be useful when developing shell scripts or Perl programs for software installation, file comparison, and detection of file corruption and tampering.
    * 还有fsum
    * HashCalc /super hash calc 一个超强的文件校验码计算工具!速度快,支持算法多,直接拖动即可计算,十分方便!还可对字串直接计算!

    2) PGP
    * The PGP signatures can be verified using PGP or GPG. First download the KEYS as well as the asc signature file for the particular distribution. Make sure you get these files from the main distribution directory, rather than from a mirror. Then verify the signatures using
    % pgpk -a KEYS
    % pgpv apache-ant-1.7.1-bin.tar.gz.asc
    or
    % pgp -ka KEYS
    % pgp apache-ant-1.7.1-bin.tar.gz.asc
    or
    % gpg --import KEYS
    % gpg --verify apache-ant-1.7.1-bin.tar.gz.asc

    A command line version of GnuPG is also available for Windows users.

    四 参考:

    http://ant.apache.org/bindownload.cgi

    http://www.fastsum.com/

    http://fsumfe.sourceforge.net/

    http://www.slavasoft.com/fsum

    五 MD5创建和验证

    1) 创建MD5验证码(fsum)

    2)验证 (super hash calc)

     完!


    作者:iTech
    微信公众号: cicdops
    出处:http://itech.cnblogs.com/
    github:https://github.com/cicdops/cicdops

  • 相关阅读:
    【2】KNN:约会对象分类器
    Android学习笔记_69_android 支付宝之网页支付和快捷支付
    风吹过你走的那一刻,带走了你最后的足印,抹拭了我唯一追寻的方向
    The connection to adb is down, and a severe error has occured.
    RSA加密算法
    Android动画之translate(位移动画)
    Android学习笔记_68_ android 9patch 图片
    android:TableLayout表格布局详解
    Android 中 shape 图形的使用
    Android学习笔记_67_Android MyCrashHandler 中异常处理 UncaughtExceptionHandler
  • 原文地址:https://www.cnblogs.com/itech/p/1612040.html
Copyright © 2011-2022 走看看