-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdecrypt.py
More file actions
32 lines (22 loc) · 768 Bytes
/
decrypt.py
File metadata and controls
32 lines (22 loc) · 768 Bytes
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
# ==============================================================================
#
# Use:
# decrypt(b'WzM3NDQyLCA1MjQ4OCwgNTU4NzQsIDU2MDcyLCA1NzQxMCwgMTcxNjAsIDQ1MTIyLCA1NzYwOCwgNTg5NDYsIDU2MDcyLCA1MTc3OCwgMTc2NzJd', "key")
# => "Hello World!"
#
# ==============================================================================
import base64
def encode(text):
encoded_arr = [ord(i) for i in text]
return encoded_arr
def decrypt(text, key):
encoded_key = encode(key)
decoded_b64 = eval(base64.b64decode(text))
buf = []
for x in decoded_b64:
encoded_key = list(reversed(encoded_key))
for i in encoded_key:
x = x - 1 >> i % 8
buf.append(x)
decrypted_string = ''.join(chr(letter) for letter in buf)
return decrypted_string