Show More
@@ -0,0 +1,25 b'' | |||||
|
1 | #! /usr/bin/env python | |||
|
2 | import sys | |||
|
3 | import os | |||
|
4 | import md5 | |||
|
5 | ||||
|
6 | for filename in sys.argv[1:]: | |||
|
7 | try: | |||
|
8 | fp = open(filename, 'rb') | |||
|
9 | except IOError, msg: | |||
|
10 | sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) | |||
|
11 | sys.exit(1) | |||
|
12 | ||||
|
13 | m = md5.new() | |||
|
14 | try: | |||
|
15 | while 1: | |||
|
16 | data = fp.read(8192) | |||
|
17 | if not data: | |||
|
18 | break | |||
|
19 | m.update(data) | |||
|
20 | except IOError, msg: | |||
|
21 | sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) | |||
|
22 | sys.exit(1) | |||
|
23 | sys.stdout.write('%s %s\n' % (m.hexdigest(), filename)) | |||
|
24 | ||||
|
25 | sys.exit(0) |
General Comments 0
You need to be logged in to leave comments.
Login now