计算器Hash or Checksum

hashfile的Python项目详细描述


hashfile以多种格式计算散列或校验和,还可以验证 他们。

默认算法是sha1。这可以通过传递参数来更改 -a/--algorithmhashfile,或者通过调用 算法名称(即使用符号链接)。

hashfile对于大文件非常有效,因为总是读取数据 部分地,默认情况下一次4MB的数据(可以使用 --max-input-readparam)。

示例

# simplest call
% hashfile /etc/hosts
sha1: 4f53fb6efebddfdbe989f3bff980cd07ebcdc6bb /etc/hosts

# specify algorithm
% hashfile -a md5 /etc/hosts
md5: 71e875e9d194c18567f48cf9534ed6cf /etc/hosts

# one file, many algorithms
% hashfile -a md5 -a sha1 /etc/hosts /etc/hosts
md5: 71e875e9d194c18567f48cf9534ed6cf /etc/hosts
sha1: 4f53fb6efebddfdbe989f3bff980cd07ebcdc6bb /etc/hosts

# many files, other algorithm for each one
% hashfile -a md5 -a sha1 /etc/hosts /etc/shells
md5: 71e875e9d194c18567f48cf9534ed6cf /etc/hosts
sha1: e0de09cb8797a4d39f89049d74585e815a3c6ceb /etc/shells

# many files, one algorithm
% hashfile -a sha256 /etc/hosts /etc/shells
sha256: 48127a192d62fdcaa39f7cebd1ea5f3fe660807c8cd3a92599406d16bddc341a /etc/hosts
sha256: edfd1953cce18ab14449b657fcc01ece6a43a7075bab7b451f3186b885c20998 /etc/shells

# choose algorithm using symlinks
% ln -s `which hashfile` ~/bin/sha256
% sha256 /etc/hosts
sha256: 48127a192d62fdcaa39f7cebd1ea5f3fe660807c8cd3a92599406d16bddc341a /etc/hosts

# create verify file, and then verify
% hashfile -a sha256 README.* > check.sum
% hashfile -c check.sum
README.md: OK
README.rst: OK

当前稳定版本

2.1.5

python版本

hashfile适用于python 2.7+和3.3+。

用法

一切都在帮助中:)只需执行:

hashfile --help

查看结果(记住:算法列表可能因系统而异):

% hashfile --help
usage: hashfile [-h]
                [--algorithm {adler32,crc32,md4,md5,mdc2,ripemd160,sha,sha1,sha224,sha256,sha384,sha512,whirlpool}]
                [--generate-algo-symlinks] [--check] [--quiet] [--status]
                [--warn] [--max-input-read MAX_INPUT_READ]
                [FILE [FILE ...]]

Calculate hash of some files

positional arguments:
  FILE                  list of files (stdin by default)

optional arguments:
  -h, --help            show this help message and exit
  --algorithm {adler32,crc32,md4,md5,mdc2,ripemd160,sha,sha1,sha224,sha256,sha384,sha512,whirlpool}, -a {adler32,crc32,md4,md5,mdc2,ripemd160,sha,sha1,sha224,sha256,sha384,sha512,whirlpool}
                        algorithm used to calculate hash If given more then
                        one, then use different algorithms for different files
                        (use first algo to first file, second algo to second
                        file etc. If there is more files then algorithms, last
                        algorithm from list is used.
  --generate-algo-symlinks
                        Show aliases for every algorithm handled by hashfile
  --check, -c           read checksums from the FILEs and check them
  --quiet, -q           don't print OK for each successfully verified file
  --status, -s          don't output anything, status code shows success
  --warn, -w            warn about improperly formatted checksum lines
  --max-input-read MAX_INPUT_READ
                        maximum data size for read at once

Algorithm can be also set from program name (for example call program as sha1
to use sha1 algorithm)

安装

  1. 使用pip

hashfile应该在任何平台上工作 Python可用,表示Linux、Windows, MacOS X等。

最简单的方法是使用python的内置包系统:

pip install hashfile
  1. 使用pipsi

    pipsi安装哈希文件

  2. 使用源

从下载源 Github

wget -O 2.1.5.zip https://github.com/msztolcman/hashfile/archive/2.1.5.zip

curl -o 2.1.5.zip https://github.com/msztolcman/hashfile/archive/2.1.5.zip

打开包装:

unzip 2.1.5.zip

并安装

cd hashfile-2.1.5
python setup.py install

喂!

作者

马辛·斯托尔克曼marcin@urzenia.net

联系人

如果你喜欢或不喜欢这个软件,请不要犹豫告诉我 关于这个我通过电子邮件(marcin@urzenia.net)。

如果你发现了bug或者有改进这个工具的想法,请使用 Github的issues

许可证

麻省理工学院许可证(MIT)

版权所有(c)2012 Marcin Sztolcman

特此免费向任何获得 本软件和相关文档文件的副本 “软件”),无限制地处理软件,包括 但不限于使用、复制、修改、合并、发布, 分发、再授权和/或出售软件副本,以及 允许向其提供软件的人员这样做,但须遵守 以下条件:

上述版权公告及本许可公告须包括在内 在软件的所有副本或大部分中。

软件按“原样”提供,不作任何形式的保证 或默示的,包括但不限于 适销性、适合特定目的和不侵权。 在任何情况下,作者或版权持有人均不对任何 索赔、损害赔偿或其他责任,无论是在合同诉讼中, 侵权行为或其他,由 软件或软件中的使用或其他交易。

更改日志

v2.1.5

  • 修复了从stdin读取二进制数据的问题

v2.1.4

  • 修复了使用二进制文件的问题
  • hashfile现在是一个包
  • 一些与软件包相关的更改
  • 对makefile的更新很少

v2.1.3

  • 修复了使用别名的问题

v2.1.2

  • pypi的另一个小改进
  • 忘记更改日志

v2.1.1

  • setup.py和pypi的小改进

v2.1.0

  • 添加–版本开关

v2.0.0

  • 增加了与md5sum或sha1sum(验证模式, 调用参数兼容性等)

v1.0.0

  • 第一个公共版本

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Netbeans hibernate pdf报告   java如何将通用JAXBElement作为输入   java如何在Spring中注入自定义ObjectFactory   使用webview下载java 安卓 instagram视频   是否可能使用Java在OpenCL上运行C应用程序?   java AbstractTableModel使用TreeMap<Integer,Vector<Object>作为实现insertRow()的基础   java使用@Transaction和spring boot 2.1回滚每个异常   java Hibernate批处理操作性能   swing从Java对象的ArrayList创建JTable   代码可读性为什么java没有相同的功能/替代方案   java Spring创建名为“org”的bean时出错。springframework。aop。配置。内部自动加速器   java如何在JTable中维护用户指定的列宽?   java FCM通知图标未更改   kryo如何在java之外向kryonet发送数据   java当记录计数很高且某些列被索引时,如何优化Oracle DB中的插入率?   ffmpeg如何使用java程序执行cmd命令