| 查看: 1013 | 回复: 11 | ||
渔夫之友铁虫 (小有名气)
|
[求助]
程序运行出差错 求解。 已有1人参与
|
|

【答案】应助回帖
感谢参与,应助指数 +1
|
import hashlib import sys def multi_hash(filename): """Calculates the md5 and sha256 hashes of the specified file and returns a list containing the hash sums as hex strings.""" md5=hashlib.md5() sha256=hashlib.sha256() with open(filename,'rb') as f: while True: buf=f.read(2**20) if not buf : break md5.update(buf) sha256.update(buf) return [md5.hexdigest(),sha256.hexdigest()] if __name__ == '__main__': hashes=[] print'-------MD5 sums--------' for filename in sys.argv[1:]: h=multi_hash(filename) hashes.append(h) print '%s %s' % (h[0],filename) print '--------SHA256 sums--------' for i in range (len(hashes)): print '%s %s' % (hashes[1],sys.argv[i+1]) # 这行修改一下 python mutilhash.py /bin/{ls,bash,sh} -------MD5 sums-------- b691e28e120f6989e37c7db21cb51931 /bin/ls 144968564a6b1159ed82059920cea76f /bin/bash ced2ebfccfe2d52f362908020acd5831 /bin/sh --------SHA256 sums-------- 1e87d99599ddea2a93f060b50a54066e8b756d752158e6147cbb99b06eb11d99 /bin/ls a186368e1b73be93a2674201124abb1fb16489812ef4aa4431004f0065d9e94b /bin/bash 103e9972afdbe01061291137705183ea5c91b3a6ba07c22a9c0a50d2eab97bcc /bin/sh |
4楼2016-10-20 00:29:14
5楼2016-10-20 00:30:59
6楼2016-10-20 00:38:08
7楼2016-10-20 00:42:42
渔夫之友
铁虫 (小有名气)
- 应助: 5 (幼儿园)
- 金币: 2585.1
- 散金: 10
- 红花: 1
- 帖子: 216
- 在线: 144.6小时
- 虫号: 2645130
- 注册: 2013-09-10
- 性别: GG
- 专业: 信息安全

2楼2016-10-18 21:48:52
渔夫之友
铁虫 (小有名气)
- 应助: 5 (幼儿园)
- 金币: 2585.1
- 散金: 10
- 红花: 1
- 帖子: 216
- 在线: 144.6小时
- 虫号: 2645130
- 注册: 2013-09-10
- 性别: GG
- 专业: 信息安全

3楼2016-10-19 07:49:57
渔夫之友
铁虫 (小有名气)
- 应助: 5 (幼儿园)
- 金币: 2585.1
- 散金: 10
- 红花: 1
- 帖子: 216
- 在线: 144.6小时
- 虫号: 2645130
- 注册: 2013-09-10
- 性别: GG
- 专业: 信息安全

8楼2016-10-20 08:40:58
渔夫之友
铁虫 (小有名气)
- 应助: 5 (幼儿园)
- 金币: 2585.1
- 散金: 10
- 红花: 1
- 帖子: 216
- 在线: 144.6小时
- 虫号: 2645130
- 注册: 2013-09-10
- 性别: GG
- 专业: 信息安全

9楼2016-10-20 08:41:12
渔夫之友
铁虫 (小有名气)
- 应助: 5 (幼儿园)
- 金币: 2585.1
- 散金: 10
- 红花: 1
- 帖子: 216
- 在线: 144.6小时
- 虫号: 2645130
- 注册: 2013-09-10
- 性别: GG
- 专业: 信息安全

10楼2016-10-20 14:18:20













回复此楼
