-
Notifications
You must be signed in to change notification settings - Fork 6
/
Caeser.py
97 lines (94 loc) · 4.36 KB
/
Caeser.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
banner = """\u001b[36;1m
█████▄ ██▀███ ▄▄▄ ▄████ ▒█████ ███▄ ▄███ ▄███ ▓▓▄ █
▒██ ██▌▓██ ▒ ██▒▒████▄ ██▒ ▀█▒▒██ ██▒ ██▒▀█▀█ █ ▒██ ██ ▄ ██ ▀█ █
░██ █▌▓██ ▄█ ▒▒██ ▀█▄ ▒██░▄▄▄░▒██░ ██ ▓██ ▓██▒ ██ ▀█▄▓ ██ ▀█ ██▒
░▓█▄ ▌▒██▀▀█▄ ░██▄▄▄▄██ ░▓█ ██▓▒██ ██░▒██ ▒██ ░██▄▄▄▄██ ▓██▒ ▐▌██▒
░▒████▓ ░██▓ ▒██▒ ▓█ ▓██▒░▒▓███▀▒░ ████▓▒░▒██▒ ░██▒ ▓█ ▓██▒▒██░ ▓██░
▒▒▓ ▒ ░ ▒▓ ░▒▓░ ▒▒ ▒█░ ░▒ ▒ ░ ▒░▒░▒░ ░ ▒░ ░ ░ ▒▒ ▓▒█░░ ▒░ ▒ ▒
░ ▒ ▒ ░▒ ░ ▒░ ▒ ▒▒ ░ ░ ░ ░ ▒ ▒░ ░ ░ ░ ▒ ▒▒ ░░ ░░ ░ ▒░
░ ░ ░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ▒ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
\u001b[32;1m
--Presented with <3 by Shivanshu Sharma
\u001b[35 __ __ ___ ___ ___ ___ ___ ___ __ __ ___ ___ ___
/ _) ( ) ( _)/ __)( _)( ,) ( \( _) / _)/ \( \( _)( ,)
( (_ /__\ ) _)\__ \ ) _) ) \ ) ) )) _)( (_( () )) ) )) _) ) \
\__)(_)(_)(___)(___/(___)(_)\_) (___/(___) \__)\__/(___/(___)(_)\_)
\u001b[32;1m \u001b[0m """
print(banner)
menu=""" \u001b[33;1m
------------------------------------------
LIST OF DECODERS |
------------------------------------------
[+] ASCII CONVERTER -- Ascii.py |
[+] ATBASH DECODER -- Atbash.py |
[+] CAESER DECODER -- Caeser.py |
[+] BACON DECODER -- Bacon.py |
[+] BASE32 DECODER -- Base32.py |
[+] BASE64 DECODER -- Base64.py |
[+] BASE85 DECODER -- Base85.py |
[+] DNA DECODER -- Dna.py |
[+] MORSE DECODER -- Morse.py |
[+] NUMBER SYSTEM -- Num.py |
[!] BINARY TO TEXT |
[!] HEX TO TEXT |
[!] OCTAL TO TEXT |
[+] RAILFENCE DECODER -- Rail.py |
[+] REVERSE CIPHER -- Reverse.py |
[+] ROTn DECODER -- Rot.py |
[+] TRANSPOSITION CIPHER -- Trans.py |
[+] VIGNERE DECODER -- Vignere.py |
------------------------------------------s
\u001b[32;1m"""
print(menu)
MAX_KEY_SIZE = 26
def getMode():
while True:
print('Do you wish to Decrypt with key [D]/ Bruteforce [B] a message?')
mode = input().lower()
if mode in ' decrypt d brute b'.split():
return mode
else:
print('Enter either "decrypt" or "D" "brute" or "B".')
def getMessage():
print('Enter your message:')
return input()
def getKey():
key = 0
while True:
print('Enter the key number (1-%s)' % (MAX_KEY_SIZE))
key = int(input())
if (key >= 1 and key <= MAX_KEY_SIZE):
return key
def getTranslatedMessage(mode, message, key):
if mode[0] == 'd':
key = -key
translated = ''
for symbol in message:
if symbol.isalpha():
num = ord(symbol)
num += key
if symbol.isupper():
if num > ord('Z'):
num -= 26
elif num < ord('A'):
num += 26
elif symbol.islower():
if num > ord('z'):
num -= 26
elif num < ord('a'):
num += 26
translated += chr(num)
else:
translated += symbol
return translated
mode = getMode()
message = getMessage()
if mode[0] != 'b':
key = getKey()
print('Your translated text is:')
if mode[0] != 'b':
print(getTranslatedMessage(mode, message, key))
else:
for key in range(1,MAX_KEY_SIZE + 1):
print(key, getTranslatedMessage('decrypt',message,key))