forked from ninthmike/chargeguy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
encrypt_string.py
42 lines (29 loc) · 881 Bytes
/
encrypt_string.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
# Simple string obfuscation to discourage string dumps.
#
import sys
from Tkinter import Tk
REPLACE_DICTIONARY = "0369cf258be147ad"
def do_string_encrypt():
r = Tk()
if len(sys.argv) == 1:
plaintext = r.clipboard_get()
print('Encrypting from clipboard: %s' % plaintext)
else:
plaintext = sys.argv[1]
print('Encrypting: %s' % plaintext)
hex_text = plaintext.encode('hex')
print('Raw hex: %s' % hex_text)
ciphertext = ""
for c in hex_text:
if c >= '0' and c <= '9':
int_value = int(c)
else:
int_value = ord(c) - ord('a') + 10
ciphertext = ciphertext + REPLACE_DICTIONARY[int_value]
print('Ciphertext: %s' % ciphertext)
r.withdraw()
r.clipboard_clear()
r.clipboard_append(ciphertext)
r.destroy()
if __name__ == '__main__':
do_string_encrypt()