Repository navigation
Expand file tree
/
Copy pathencrypted3.py
More file actions
160 lines (143 loc) · 5.4 KB
/
Copy pathencrypted3.py
File metadata and controls
160 lines (143 loc) · 5.4 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
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Encode & Decode Utility 25 Methods by 0x101Cyb3r
Deskripsi : Gabungan Bash-style interface dan logika Python
RUN : python3 encrypted3.py -file input.txt -output output.txt
"""
import sys, os, base64, hashlib, urllib.parse, zlib, binascii
try:
import pybase58
except:
pybase58 = None
def banner():
print("="*38)
print(" UNIVERSAL ENCODE/DECODE TOOL")
print("="*38)
print(" 1. Base64")
print(" 2. Base32")
print(" 3. Base85")
print(" 4. Hexadecimal")
print(" 5. ROT13")
print(" 6. URL Encode")
print(" 7. URL Decode")
print(" 8. Caesar Cipher (+3)")
print(" 9. Binary Encode")
print("10. Binary Decode")
print("11. Morse Code Encode")
print("12. Morse Code Decode")
print("13. Reverse String")
print("14. XOR Cipher")
print("15. MD5 Hash")
print("16. SHA1 Hash")
print("17. SHA256 Hash")
print("18. UUEncode")
print("19. UUDecode")
print("20. Zlib Compress")
print("21. Zlib Decompress")
print("22. ASCII85 Encode")
print("23. ASCII85 Decode")
print("24. Base58 Encode")
print("25. Base58 Decode")
print("="*38)
def caesar(text, shift=3, decode=False):
if decode: shift = -shift
result = ""
for c in text:
if c.isalpha():
base = ord('A') if c.isupper() else ord('a')
result += chr((ord(c) - base + shift) % 26 + base)
else:
result += c
return result
def xor_cipher(text, key='X'):
return ''.join(chr(ord(c) ^ ord(key)) for c in text)
def morse_tables():
MORSE = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.',
'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.',
'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..', '1': '.----', '2': '..---', '3': '...--',
'4': '....-', '5': '.....', '6': '-....', '7': '--...', '8': '---..',
'9': '----.', '0': '-----', ' ': '/'}
REVMORSE = {v: k for k, v in MORSE.items()}
return MORSE, REVMORSE
def process(method, mode, data):
MORSE, REVMORSE = morse_tables()
if method == 1:
return base64.b64encode(data.encode()).decode() if mode=="encode" else base64.b64decode(data).decode()
elif method == 2:
return base64.b32encode(data.encode()).decode() if mode=="encode" else base64.b32decode(data).decode()
elif method == 3:
return base64.b85encode(data.encode()).decode() if mode=="encode" else base64.b85decode(data).decode()
elif method == 4:
return binascii.hexlify(data.encode()).decode() if mode=="encode" else binascii.unhexlify(data).decode()
elif method == 5:
import codecs
return codecs.encode(data, 'rot_13')
elif method == 6:
return urllib.parse.quote(data)
elif method == 7:
return urllib.parse.unquote(data)
elif method == 8:
return caesar(data, 3, decode=(mode=="decode"))
elif method == 9:
return ' '.join(format(ord(i), '08b') for i in data)
elif method == 10:
return ''.join(chr(int(b, 2)) for b in data.split())
elif method == 11:
return ' '.join(MORSE.get(c.upper(), '') for c in data)
elif method == 12:
return ''.join(REVMORSE.get(c, '') for c in data.split())
elif method == 13:
return data[::-1]
elif method == 14:
return xor_cipher(data)
elif method == 15:
return hashlib.md5(data.encode()).hexdigest()
elif method == 16:
return hashlib.sha1(data.encode()).hexdigest()
elif method == 17:
return hashlib.sha256(data.encode()).hexdigest()
elif method == 18:
return base64.encodebytes(data.encode()).decode()
elif method == 19:
return base64.decodebytes(data.encode()).decode()
elif method == 20:
return base64.b64encode(zlib.compress(data.encode())).decode()
elif method == 21:
return zlib.decompress(base64.b64decode(data)).decode()
elif method == 22:
return base64.a85encode(data.encode()).decode()
elif method == 23:
return base64.a85decode(data).decode()
elif method == 24 and pybase58:
return pybase58.b58encode(data.encode()).decode()
elif method == 25 and pybase58:
return pybase58.b58decode(data).decode()
else:
return "[!] Metode tidak tersedia atau library belum terpasang."
def main():
# Parsing argumen seperti bash
args = sys.argv[1:]
if "-file" not in args or "-output" not in args:
print("Gunakan: python3 encrypted3.py -file input.txt -output output.txt")
sys.exit(1)
input_file = args[args.index("-file")+1]
output_file = args[args.index("-output")+1]
if not os.path.exists(input_file):
print(f"[x] File '{input_file}' tidak ditemukan.")
sys.exit(1)
with open(input_file, "r", encoding="utf-8") as f:
data = f.read().strip()
banner()
method = int(input("Pilih nomor metode (1-25): "))
mode = input("Pilih mode (encode/decode): ").lower()
print("\n[+] Memproses...\n")
result = process(method, mode, data)
with open(output_file, "w", encoding="utf-8") as f:
f.write(result)
print(f"[✔] Proses {mode.upper()} selesai.")
print(f"[✔] Hasil disimpan di: {output_file}")
if __name__ == "__main__":
main()