forked from PrasoonJain2002/Mini_Python_Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaesar_solver.py
More file actions
40 lines (35 loc) · 764 Bytes
/
caesar_solver.py
File metadata and controls
40 lines (35 loc) · 764 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
33
34
35
36
37
38
39
40
print('caesar cipher solver')
def bruteforce():
print('enter the ciphertext:')
s = input()
s.upper()
for i in range(1,26):
print('--------------------------------------')
print('key = {}'.format(i))
c = ''
for j in s:
c+= chr((ord(j) + i-65) % 26 + 65)
print(c)
def encrypt():
s = input("enter text to encrypt")
k = int(input("enter key"))
c = ''
for j in s:
c+= chr((ord(j) + k-65) % 26 + 65)
print(c)
def decrypt():
s = input("enter text to decrypt")
k = int(input("enter key"))
c = ''
for j in s:
c+= chr((ord(j) + k-65) % 26 + 65)
print(c)
n = int(input("Choose your option:\n[1]Encrypt\n[2]Decrypt\n[3]Bruteforce"))
if n == 1:
encrypt()
elif n == 2:
decrypt()
elif n == 3:
bruteforce()
else:
print("Enter proper value")