计算器Hash or Checksum
hashfile的Python项目详细描述
hashfile以多种格式计算散列或校验和,还可以验证 他们。
默认算法是sha1。这可以通过传递参数来更改 -a/--algorithm到hashfile,或者通过调用 算法名称(即使用符号链接)。
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)
安装
- 使用pip
hashfile应该在任何平台上工作 Python可用,表示Linux、Windows, MacOS X等。
最简单的方法是使用python的内置包系统:
pip install hashfile
使用pipsi
pipsi安装哈希文件
使用源
从下载源 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
喂!
许可证
麻省理工学院许可证(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
- 第一个公共版本