-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
encrypt_code.py
28 lines (22 loc) · 907 Bytes
/
encrypt_code.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
#!/usr/bin/env python
import base64
class Encrypt:
def __init__(self):
self.YELLOW, self.GREEN = '\33[93m', '\033[1;32m'
self.text = ""
self.enc_txt = ""
def encrypt(self, filename):
print(f"\n{self.YELLOW}[*] Encrypting Source Codes...")
with open(filename, "r") as f:
lines_list = f.readlines()
for lines in lines_list:
self.text += lines
self.text = self.text.encode()
self.enc_txt = base64.b64encode(self.text)
with open(filename, "w") as f:
f.write(f"import base64; exec(base64.b64decode({self.enc_txt}))")
print(f"{self.GREEN}[+] Operation Completed Successfully!\n")
if __name__ == '__main__':
test = Encrypt()
filename = input("Please Enter Filename: ")
test.encrypt(filename)