-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrotter.py
More file actions
176 lines (124 loc) · 5.28 KB
/
Copy pathrotter.py
File metadata and controls
176 lines (124 loc) · 5.28 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import os
import beaupy
import codecs
from pystyle import Colors, Colorate
##--------------------------Functions------------------------------##
def banner():
banner = """
▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄▄▄ .▄▄▄
▀▄ █·▪ •██ •██ ▀▄.▀·▀▄ █·
▐▀▀▄ ▄█▀▄ ▐█.▪ ▐█.▪▐▀▀▪▄▐▀▀▄
▐█•█▌▐█▌.▐▌ ▐█▌· ▐█▌·▐█▄▄▌▐█•█▌
.▀ ▀ ▀█▄▀▪ ▀▀▀ ▀▀▀ ▀▀▀ .▀ ▀
Made by 0x4b | https://github.com/0xNibble
"""
colored_banner = Colorate.Horizontal(Colors.purple_to_blue, banner, 1)
return colored_banner
def clear():
os.system("clear||cls")
#Rot47 Encode & Decode
def r47e(message: str) -> str:
encoded_message = ""
for char in message:
char_code = ord(char)
if char_code >= 33 and char_code <= 126:
char_code -= 47
if char_code < 33:
char_code += 94
encoded_message += chr(char_code)
return encoded_message
def r47d(message: str) -> str:
decoded_message = ""
for char in message:
char_code = ord(char)
if char_code >= 33 and char_code <= 126:
char_code += 47
if char_code > 126:
char_code -= 94
decoded_message += chr(char_code)
return decoded_message
#Rot13 Encode & Decode
def r13e(message: str) -> str:
return codecs.encode(message, "rot13")
def r13d(message: str) -> str:
return codecs.decode(message, "rot13")
##--------------------------Functions End---------------------------------##
##--------------------------Main Code---------------------------------##
def main():
options = ['Rot13', 'Rot47', 'Exit?']
while True:
clear()
print(f'{banner()}\n\nWhat would you like to do? - (Main Menu)\n-----------------------------------------------------------\n')
option = beaupy.select(options, cursor_style="#ffa533")
if not option:
clear()
exit("Keyboard Interuption Detected!\nGoodbye!")
if options[0] in option:
while True:
clear()
rot13_options = ['Encode?', 'Decode', 'Back?']
print(f'{banner()}\n\nWhat would you like to do? - (Rot13)\n-----------------------------------------------------------\n')
rot13_option = beaupy.select(rot13_options, cursor_style="#ffa533")
if not rot13_option:
clear()
break
if rot13_options[0] in rot13_option:
clear()
m13e = beaupy.prompt("What would you like to encode?")
if not m13e or m13e == '':
clear()
break
data13e = r13e(m13e)
clear()
print(f"Here is your encodded message: {data13e}\n\n")
input('Press "enter" to continue...')
if rot13_options[1] in rot13_option:
clear()
m13d = beaupy.prompt("What would you like to decode?")
if not m13d or m13d == '':
clear()
break
data13d = r13d(m13d)
clear()
print(f"Here is your decodded message: {data13d}\n\n")
input('Press "enter" to continue...')
if rot13_options[2] in rot13_option:
clear()
break
if options[1] in option:
while True:
clear()
rot47_options = ['Encode?', 'Decode', 'Back?']
print(f'{banner()}\n\nWhat would you like to do? - (Rot47)\n-----------------------------------------------------------\n')
rot47_option = beaupy.select(rot47_options, cursor_style="#ffa533")
if not rot47_option:
clear()
break
if rot47_options[0] in rot47_option:
clear()
m47e = beaupy.prompt("What would you like to encode?")
if not m47e or m47e == '':
clear()
break
data47e = r47e(m47e)
print(f'Here is your encodded message: {data47e}\n\n')
input('Press "enter" to continue...')
if rot47_options[1] in rot47_option:
clear()
m47d = beaupy.prompt("What would you like to decode?")
if not m47e or m47e == '':
clear()
break
data47d = r47d(m47d)
print(f'Here is your decodded message: {data47d}\n\n')
input('Press "enter" to continue...')
if rot47_options[2] in rot47_option:
clear()
break
if options[2] in option:
clear()
exit("Goodbye")
##--------------------------Main Code End---------------------------------##
if __name__ == '__main__':
clear()
main()