-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathceaser.py
More file actions
31 lines (19 loc) · 713 Bytes
/
ceaser.py
File metadata and controls
31 lines (19 loc) · 713 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
from string import maketrans, translate
alphabet = "abcdefghijklmnopqrstuvwxyz"
def brute_force() :
code = raw_input("Enter your code text: ")
for offset in range (26) :
ceaser = alphabet[offset:] + alphabet[0:offset]
trans = maketrans(alphabet, ceaser)
print translate(code, trans)
def encode() :
offset = 10
ceaser = alphabet[offset:] + alphabet[0:offset]
trans = maketrans(alphabet, ceaser)
phrase = raw_input("Enter your plaintext phrase: ")
print translate(phrase, trans)
answer = raw_input("(encode) or (break) a Code?: ")
if answer == "break" :
brute_force()
else :
encode()