md5.py
1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python
#encoding=utf-8
import os
import io
import sys
import hashlib
import string
import subprocess
def printUsage():
print ('''Usage: [python] md5.py <filename> <module>''')
print (''' module has two optional value: jp,rn''')
print (''' default is jp''')
def write2Clipboard(output):
process = subprocess.Popen(
'pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
process.communicate(output.encode('utf-8'))
def calMd5(filename, module="jp"):
print("🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅🍅")
if not os.path.isfile(filename):
print("👿 file doesn't exist\t" + filename)
return
m0 = hashlib.md5()
file = io.FileIO(filename,'r')
bytes = file.read(8096)
while(bytes != b''):
m0.update(bytes)
bytes = file.read(8096)
file.close()
md5value = m0.hexdigest()
print("😇 file\t\t\t" + filename)
print("😌 file md5 value\t" + md5value)
suffixes = "yohopatch2016"
if module == 'rn':
suffixes = "yohorn2016"
m1 = hashlib.md5()
source = md5value + suffixes
m1.update(source.encode("utf8"))
sourceMd5value = m1.hexdigest()
print("😏 string\t\t" + source)
print("😋 string md5 value\t" + sourceMd5value)
write2Clipboard(sourceMd5value)
print("😀 the value already write to your clipboard\t")
print("🚀 🚁 ✈️ now you can use command + v to paste it!!!\t")
print("🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊🍊")
def main():
if(sys.argv.__len__() == 2):
calMd5(sys.argv[1])
elif(sys.argv.__len__() == 3):
calMd5(sys.argv[1], sys.argv[2])
else:
printUsage()
main()