-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhashme.py
549 lines (495 loc) · 17.3 KB
/
hashme.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
#!/usr/bin/env python
#coding: utf-8
#AUTHOR : DEVIL MASTER
import hashlib
from base64 import *
import codecs
import binascii
import re
from time import sleep
import sys
from platform import python_version
from art import *
from os import system, name
from Crypto.Hash import MD2, MD4
########################### BEGIN ###########################
def author():
print(" \033[37m[\033[31m|\033[37m]|------------------------------------------------|\033[37m[\033[31m|\033[37m]")
print(" \033[37m[\033[31m|\033[37m]| DEVELOPED BY DEVIL MASTER |\033[37m[\033[31m|\033[37m]")
print(" \033[37m[\033[31m|\033[37m]| github.com/isuruwa |\033[37m[\033[31m|\033[37m]")
print(" \033[37m[\033[31m|\033[37m]|------------------------------------------------|\033[37m[\033[31m|\033[37m]\n")
if sys.version_info[0] < 3:
versao = python_version()
print(
"\n\033[32m You are using python in the version\033[1;m \033[1m\033[31m%s\033[1;m \033[32mand it is lower than python3 onwards.\033[1;m"
% (versao))
print(
"\033[32m Please run HashCode with a higher version than python2\033[1;m\n"
)
exit(1)
def clear():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
def banner(topic):
clear()
print("\033[1;32m")
tprint(topic)
author()
def re(reb, again):
rec = input(reb)
if rec == "y" or rec == "Y":
again()
elif rec == "n" or rec == "N":
menu()
else:
re(reb,again)
########################### MENU ###########################
def menu():
banner(""" HASHME\n""")
print("\033[35m [\033[37m1\033[35m]\033[37m ENCODE MD2")
print("\033[35m [\033[37m2\033[35m]\033[36m ENCODE MD4")
print("\033[35m [\033[37m3\033[35m]\033[1;32m Encode MD5")
print("\033[35m [\033[37m4\033[35m]\033[34m Encode SHA1")
print("\033[35m [\033[37m5\033[35m]\033[35m Encode SHA224")
print("\033[35m [\033[37m6\033[35m]\033[36m ENCODE SHA256")
print("\033[35m [\033[37m7\033[35m]\033[37m ENCODE SHA384")
print("\033[35m [\033[37m8\033[35m]\033[1;32m ENCODE SHA512")
print("\033[35m [\033[37m9\033[35m]\033[37m ENCODE SHA3-224")
print("\033[35m [\033[37m10\033[35m]\033[36m ENCODE SHA3-256")
print("\033[35m [\033[37m11\033[35m]\033[37m ENCODE SHA3-512")
print("\033[35m [\033[37m12\033[35m]\033[31m ENCODE|DECODE BASE64")
print("\033[35m [\033[37m13\033[35m]\033[35m ENCODE|DECODE BINARY")
print("\033[35m [\033[37m14\033[35m]\033[36m ENCODE|DECODE CIPHER OF CESAR")
print("\033[35m [\033[37m15\033[35m]\033[31m ENCODE|DECODE HEXADECIMAL")
print("\033[35m [\033[37m16\033[35m]\033[1;32m ENCODE|DECODE REVERSE\n")
choice = input("\033[37m [\033[31m+\033[37m] Enter Choice : ")
if choice == "1" or choice == "01":
md2()
elif choice == "2" or choice == "02":
md4()
elif choice == "3" or choice == "03":
md5()
elif choice == "4" or choice == "04":
sha1()
elif choice == "5" or choice == "05":
sha224()
elif choice == "6" or choice == "06":
sha256()
elif choice == "7" or choice == "07":
sha384()
elif choice == "8" or choice == "08":
sha512()
elif choice == "9" or choice == "09":
sha3224()
elif choice == "10":
sha3256()
elif choice == "11":
sha3512()
elif choice == "12":
base64()
elif choice == "13":
binary()
elif choice == "14":
coc()
elif choice == "15":
hexa()
elif choice == "16":
reverse()
elif choice == "":
menu()
else:
print("\033[37m [\033[31m+\033[37m] WRONG CHOICE")
sleep(2)
menu()
########################### MD5 ###########################
def md5():
banner("""MD5""")
text = input("\033[1;32m [+] Text To Encrypt In MD5 : ")
hash = hashlib.md5(text.encode())
print("\n")
print("\033[1;32m [+] Result : " + hash.hexdigest())
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ",md5)
########################### SHA1 ###########################
def sha1():
banner("""SHA1""")
text = input("\033[1;32m [+] Text To Encrypt In SHA1 : ")
hash = hashlib.sha1(text.encode())
print("\n")
print("\033[1;32m [+] Result : " + hash.hexdigest())
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", sha1)
########################### SHA224 ###########################
def sha224():
banner("""SHA224""")
text = input("\033[1;32m [+] Text To Encrypt In SHA224 : ")
hash = hashlib.sha224(text.encode())
print("\n")
print("\033[1;32m [+] : " + hash.hexdigest())
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", sha224)
########################### SHA256 ###########################
def sha256():
banner("""SHA256""")
text = input("\033[1;32m [+] Text To Encrypt In SHA256 : ")
hash = hashlib.sha256(text.encode())
print("\n")
print("\033[1;32m [+] Result : " + hash.hexdigest())
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", sha256)
########################### SHA384 ###########################
def sha384():
banner("""SHA384""")
text = input("\033[1;32m [+] Text To Encrypt In SHA384 : ")
hash = hashlib.sha384(text.encode())
print("\n")
print("\033[1;32m [+] Result : " + hash.hexdigest())
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", sha384)
########################### SHA512 ###########################
def sha512():
banner("""SHA512""")
text = input("\033[1;32m [+] Text To Encrypt In SHA512 : ")
hash = hashlib.sha512(text.encode())
print("\n")
print("\033[1;32m [+] Result : " + hash.hexdigest())
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", sha512)
########################### BASE64 ###########################
def base64():
banner("""BASE64""")
print("\033[1;32m [+] Choose a Option : \n")
print("\033[1;32m [1] BASE64 - ENCODE ")
print("\033[1;32m [2] BASE64 - DECODE \n")
option = input("\033[37m [+] Enter Option : ")
if option == "1" or option == "01":
base64encode()
if option == "2" or option == "02":
base64decode()
else:
base64()
def base64encode():
banner("""BASE64""")
text = input("\033[1;32m [+] Text To BASE64 : ")
b64e = b64encode(text.encode('utf-8'))
b64d = b64e.decode('utf-8')
print("\n")
print("\033[1;32m [+] Result : " + b64d)
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", base64encode)
def base64decode():
banner("""BASE64""")
text = input("\033[1;32m [+] BASE64 TO TEXT : ")
try:
b64d = b64decode(text).decode('utf-8')
print("\n")
print("\033[1;32m [+] Result : " + b64d)
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", base64decode)
except:
print("\033[1;32m [+] Incorrect Padding")
print("\n")
time.sleep(2)
base64decode()
########################### BINARY ###########################
def binary():
banner("""BINARY""")
print("\033[1;32m [+] Choose a Option : \n")
print("\033[1;32m [1] BINARY - ENCODE ")
print("\033[1;32m [2] BINARY - DECODE \n")
option = input("\033[37m [+] Enter Option : ")
if option == "1" or option == "01":
binaryencode()
if option == "2" or option == "02":
binarydecode()
else:
binary()
def int2bytes(i):
hex_string = '%x' % i
n = len(hex_string)
return binascii.unhexlify(hex_string.zfill(n + (n & 1)))
def binarydecode(encoding='utf-8', errors='surrogatepass'):
banner("""BINARY""")
try:
text = input("\033[1;32m [+] BINARY TO TEXT : ")
hash = text.replace(" ", "")
bi = int(hash, 2)
print("\n")
print("\033[1;32m [+] Result : " + int2bytes(bi).decode(encoding, errors))
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", binarydecode)
except:
print("\033[1;32m [+] Error Value")
print("\n")
sleep(2)
binarydecode()
def binaryencode(encoding='utf-8', errors='surrogatepass'):
banner("""BINARY""")
try:
text = input("\033[1;32m [+] BINARY TO TEXT : ")
bits = bin(int(binascii.hexlify(text.encode(encoding, errors)),
16))[2:]
print("\n")
print("\033[1;32m [+] Result : " + bits.zfill(8 * ((len(bits) + 7) // 8)))
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", base64encode)
except:
print("\033[1;32m [+] Error Value")
print("\n")
sleep(2)
binaryencode()
########################### HEXADECIMAL ###########################
def hexa():
banner("""HEXADECIMAL""")
print("\033[1;32m [+] Choose a Option : \n")
print("\033[1;32m [1] HEXADECIMAL - ENCODE")
print("\033[1;32m [2] HEXADECIMAL - DECODE \n")
option = input("\033[37m [+] Enter Option : ")
if option == "1" or option == "01":
hexaencode()
if option == "2" or option == "02":
hexadecode()
def hexaencode():
text = input("\033[1;32m [+] TEXT TO HEXADECIMAL")
print("")
encode = binascii.hexlify(bytes(text, "utf-8"))
encode = str(encode).strip("b")
encode = encode.strip("'")
encode = re.sub(r'(..)', r'\1 ', encode).strip()
print("\n")
print("\033[1;32m [+] Result : " + encode)
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", hexaencode)
def hexadecode():
try:
text = input("\033[1;32m [+] HEXADECIAML TO TEXT : ")
print("")
decode = bytes.fromhex(text).decode('utf-8')
print("\n")
print("\033[1;32m [+] Result : " + decode)
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", hexadecode)
except:
print("Error Value")
print("\n")
sleep(2)
hexadecode()
########################### CIPHER OF CESAR ###########################
def coc():
banner("""CIPHER OF CESAR""")
print("\033[1;32m [+] Choose a Option : \n")
print("\033[1;32m [1] CIPHER OF CESAR - ENCODE ")
print("\033[1;32m [2] CIPHER OF CESAR - DECODE \n")
option = input("\033[37m [+] Enter Option : ")
if option == "1" or option == "01":
cocencode()
if option == "2" or option == "02":
cocdecode()
def cifrar(palavras, chave):
abc = "abcdefghijklmnopqrstuvwxyz "
text_cifrado = ''
for letra in palavras:
soma = abc.find(letra) + chave
modulo = int(soma) % len(abc)
text_cifrado = text_cifrado + str(abc[modulo])
return text_cifrado
def decifrar(palavras, chave):
abc = "abcdefghijklmnopqrstuvwxyz "
text_cifrado = ''
for letra in palavras:
soma = abc.find(letra) - chave
modulo = int(soma) % len(abc)
text_cifrado = text_cifrado + str(abc[modulo])
return text_cifrado
def cocencode():
banner("""CIPHER OF CESAR""")
try:
text = str(input("\033[1;32m [+] TEXT TO CIPHER: ")).lower()
key = int(input("\033[1;32m [+] ENTER KEY : "))
print("\n")
print("\033[1;32m [+] RESULT : ", cifrar(text, key))
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", cocencode)
except:
print("VALUE ERROR")
print("\n")
time.sleep(2)
cocencode()
def cocdecode():
banner("""CIPHER OF CESAR""")
try:
text = str(input("\033[1;32m [+] CYPHER TO TEXT : ")).lower()
key = int(input("\033[1;32m [+] ENTER KEY : "))
print("\n")
print("\033[1;32m [+] RESULT : ", decifrar(text, key))
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", cocdecode)
except:
print("VALUE ERROR")
print("\n")
time.sleep(2)
cocdecode()
################## md2 ######################
def md2():
banner("""MD2""")
text = str(input("\033[1;32m [+] TEXT TO MD2 : "))
hashObject = MD2.new()
hashObject.update(text.encode('utf-8'))
digest = hashObject.hexdigest()
print("\033[1;32m [+] RESULT : " , (digest))
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", cocdecode)
############## md4 ##############################
def md4():
banner("""MD4""")
text = str(input("\033[1;32m [+] TEXT TO MD2 : "))
hashObject = MD4.new()
hashObject.update(text.encode('utf-8'))
digest = hashObject.hexdigest()
print("\033[1;32m [+] RESULT : " , (digest))
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", cocdecode)
##################### sha3-224 ################################
def sha3224():
banner("""SHA3-224""")
text = str(input("\033[1;32m [+] TEXT TO SHA-224 : "))
hashObject = hashlib.sha3_224(text.encode('utf-8'))
digest = hashObject.hexdigest()
print("\033[1;32m [+] RESULT : " , (digest))
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", cocdecode)
##################### sha3-256 ################################
def sha3256():
banner("""SHA3-256""")
text = str(input("\033[1;32m [+] TEXT TO SHA-256 : "))
hashObject = hashlib.sha3_256(text.encode('utf-8'))
digest = hashObject.hexdigest()
print("\033[1;32m [+] RESULT : " , (digest))
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", cocdecode)
##################### sha3-384 ################################
def sha3384():
banner("""SHA3-384""")
text = str(input("\033[1;32m [+] TEXT TO SHA-384 : "))
hashObject = hashlib.sha3_384(text.encode('utf-8'))
digest = hashObject.hexdigest()
print("\033[1;32m [+] RESULT : " , (digest))
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", cocdecode)
##################### sha3-512 ################################
def sha3512():
banner("""SHA3-512""")
text = str(input("\033[1;32m [+] TEXT TO SHA-384 : "))
hashObject = hashlib.sha3_512(text.encode('utf-8'))
digest = hashObject.hexdigest()
print("\033[1;32m [+] RESULT : " , (digest))
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", cocdecode)
#################### base32 ############################
def base32():
banner("""BASE64""")
print("\033[1;32m [+] Choose a Option : \n")
print("\033[1;32m [1] BASE32 - ENCODE ")
print("\033[1;32m [2] BASE32 - DECODE \n")
option = input("\033[37m [+] Enter Option : ")
if option == "1" or option == "01":
base32encode()
if option == "2" or option == "02":
base32decode()
else:
base32()
def base32encode():
banner("""BASE64""")
text = input("\033[1;32m [+] Text To BASE64 : ")
b32e = base64.b32encode(text.encode('utf-8')).decode('utf-8')
print("\n")
print("\033[1;32m [+] Result : " + b32e)
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", base32encode)
def base32decode():
banner("""BASE32""")
text = input("\033[1;32m [+] BASE32 TO TEXT : ")
try:
b32d = base64.b32decode(base32Str).decode('utf-8')
print("\n")
print("\033[1;32m [+] Result : " + b32d)
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", base32decode)
except:
print("\033[1;32m [+] Incorrect Padding")
print("\n")
time.sleep(2)
base32decode()
#################### base32 ############################
def base58():
banner("""BASE58""")
print("\033[1;32m [+] Choose a Option : \n")
print("\033[1;32m [1] BASE58 - ENCODE ")
print("\033[1;32m [2] BASE58 - DECODE \n")
option = input("\033[37m [+] Enter Option : ")
if option == "1" or option == "01":
base58encode()
if option == "2" or option == "02":
base58decode()
else:
base58()
def base58encode():
banner("""BASE58""")
text = input("\033[1;32m [+] Text To BASE58 : ")
base58s = base58.b58encode(text.encode('utf-8')).decode('utf-8')
print("\n")
print("\033[1;32m [+] Result : " + base58s)
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", base58encode)
def base58decode():
banner("""BASE58""")
text = input("\033[1;32m [+] BASE58 TO TEXT : ")
try:
base58d = base58.b58decode(base58Str).decode('utf-8')
print("\n")
print("\033[1;32m [+] Result : " + b32d)
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", base58decode)
except:
print("\033[1;32m [+] Incorrect Padding")
print("\n")
time.sleep(2)
base58decode()
########################### REVERSE ###########################
def reverse():
banner("""REVERSE""")
print("\033[1;32m [+] Choose a Option : \n")
print("\033[1;32m [1] REVERSE TEXT - ENCODE")
print("\033[1;32m [2] REVERSE TEXT - DECODE \n")
option = input("\033[37m [+] Enter Option : ")
if option == "1" or option == "01":
revencode()
if option == "2" or option == "02":
revdecode()
def revencode():
banner("""REVERSE""")
text = input("\033[1;32m [+] TEXT TO REVERSE : ")
print("\n")
print("\033[1;32m [+] Result : " + text[::-1])
print("\n")
re("\033[31m [+] Do a another encode (y/n) ? ", revencode)
def revdecode():
banner("""REVERSE""")
text = input("\033[1;32m [+] REVERSE TO TEXT : ")
print("\n")
print("\033[1;32m [+] Result : " + text[::-1])
print("\n")
re("\033[31m [+] Do a another decode (y/n) ? ", revdecode)
def program():
try:
menu()
except KeyboardInterrupt:
con = input("\n\n\033[31m [c] Continue [q] Quit : ")
if con == "c" or con == "C" or con == "continue" or con == "Continue":
menu()
else:
exit()
if '__main__' == __name__:
program()