|
1 | | -#!/usr/bin/env python2 |
| 1 | +#!/usr/bin/env python3 |
2 | 2 |
|
3 | 3 | import os, argparse |
4 | 4 | from getpass import getpass |
5 | | -# sudo pip install pycryptodome==3.6.1 |
| 5 | +# sudo pip3 install pycryptodome // 3.21.0 |
6 | 6 | from Crypto.Cipher import AES |
7 | 7 | from Crypto.Hash import SHA256 |
8 | 8 | from Crypto import Random |
@@ -40,7 +40,7 @@ def encrypt(key, filename, ig): |
40 | 40 | size = os.path.getsize(filename) #+ 16 |
41 | 41 | filesize = str(size).zfill(16) |
42 | 42 | IV = Random.new().read(16) |
43 | | - secret = "0000hack1lab0000" |
| 43 | + secret = "0000hack1lab0000".encode("utf-8") |
44 | 44 |
|
45 | 45 | encryptor = AES.new(key, AES.MODE_CBC, IV) |
46 | 46 |
|
@@ -80,15 +80,16 @@ def decrypt(key, filename): |
80 | 80 | if len(chunk) == 0: |
81 | 81 | break |
82 | 82 |
|
83 | | - chunk = str(decryptor.decrypt(chunk)) |
84 | | - chunk = chunk.replace("0000hack1lab0000", "") |
| 83 | + #chunk = str(decryptor.decrypt(chunk)) |
| 84 | + chunk = decryptor.decrypt(chunk) |
| 85 | + chunk = chunk.replace("0000hack1lab0000".encode("utf-8"), "".encode("utf-8")) |
85 | 86 | outfile.write(chunk) |
86 | 87 | outfile.truncate(filesize) |
87 | 88 |
|
88 | 89 |
|
89 | 90 | def check(key, filename): |
90 | 91 | chunksize = 64# * 1024 |
91 | | - secret = "0000hack1lab0000" |
| 92 | + secret = "0000hack1lab0000".encode("utf-8") |
92 | 93 |
|
93 | 94 | with open(filename, 'rb') as infile: |
94 | 95 | IV = infile.read(16) |
|
0 commit comments