-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathralpha.py
executable file
·77 lines (71 loc) · 2.13 KB
/
ralpha.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
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# "Reverse alphabet cipher"
import sys
table0 = {"a": "z",
"b": "y",
"c": "x",
"d": "w",
"e": "v",
"f": "u",
"g": "t",
"h": "s",
"i": "r",
"j": "q",
"k": "p",
"l": "o",
"m": "n",
"n": "m",
"o": "l",
"p": "k",
"q": "j",
"r": "i",
"s": "h",
"t": "g",
"u": "f",
"v": "e",
"w": "d",
"x": "c",
"y": "b",
"z": "a"}
def decode(string, translate=False, html_mode=False):
array = []
for character in string:
if character in table0.keys():
array.append(table0[character])
elif character.lower() in table0.keys():
array.append(table0[character.lower()].upper())
else:
array.append(character)
if translate:
if html_mode:
array.append("<br>")
else:
array.append("\n")
array.append(string)
return "".join(array)
def main(argv=[]):
vinfo = tuple(str(x) for x in sys.version_info[:3])
print("Reverse Alphabet Cipher (Python %s)" % (".".join(vinfo),))
print("Enter blank input for options...")
x = " ".join(argv)
options = {"translation": False, "HTML mode": False}
if len(x) == 0:
x = input("> ")
while 1:
if x == "":
y = input("Options\n%s\n>>> " % ("\n".join([x[0][0] + ": " + ("Disable " if x[1] else "Enable ") + x[0] for x in options.items()])))
changed = False
for key in options.keys():
if y.lower() == str(key)[0].lower():
options[key] = not options[key]
print("%s %s." % (key.capitalize(), "enabled" if options[key] else "disabled"))
changed = True
break
if not changed:
print("Nothing changed.")
else:
print(decode(x, options["translation"], options["HTML mode"]))
x = input("> ")
if __name__ == "__main__":
main(sys.argv[1::])