Skip to content

Commit c3030f8

Browse files
committed
Merge pull request #265 from stonebig/master
hash report generator
2 parents d16696e + ac4e5f1 commit c3030f8

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

hash.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Tue Jun 23 21:30:06 2015
4+
5+
@author: famille
6+
"""
7+
8+
import io
9+
import os
10+
import sys
11+
import hashlib
12+
13+
14+
def give_hash(file_in, with_this):
15+
with io.open(file_in, 'rb') as f:
16+
return with_this(f.read()).hexdigest()
17+
18+
19+
if __name__ == '__main__':
20+
if (len(sys.argv) < 2):
21+
print ("Usage: " + sys.argv[0] + " github-user [github-project]")
22+
exit(1)
23+
file = sys.argv[1]
24+
25+
header = (" MD5"+" "*(32-4)+" | SHA-1"+" "*(40-5)+" | SHA-256"+
26+
" "*(64-7)+" | Binary"+" "*(31-5)+"| Size"+" "*(20-6))
27+
line = "|".join(["-"*len(i) for i in header.split("|")])
28+
29+
print(header)
30+
print(line)
31+
print ("%s | %s | %s | %s | %s" % (give_hash(file, hashlib.md5),
32+
give_hash(file, hashlib.sha1),
33+
give_hash(file, hashlib.sha256),
34+
'{0:31s}'.format(os.path.basename(file)),
35+
('{0:12,}'.format(os.path.getsize(file)).replace(","," ")+ ' Bytes')
36+
))

hash_launch.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
call D:\WinPython-64bit-3.4.3.7Qt5\scripts\env.bat
2+
3+
cd %~dp0
4+
5+
echo %date% %time%>>gdc_counting.txt
6+
python hash.py %1 >>hash_counting_%date:/=_%.txt
7+
8+
start notepad.exe hash_counting_%date:/=_%.txt

0 commit comments

Comments
 (0)