-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecrypt-ceaser.py
38 lines (31 loc) · 1.13 KB
/
decrypt-ceaser.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
import configparser
configParser = configparser.RawConfigParser()
configFilePath = r'config.txt'
configParser.read(configFilePath)
def decrypt(msg, step):
outText = []
cryptText = []
caps = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
nocaps = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for letter in msg:
if letter in caps:
contents = caps.index(letter)
decrypt = (contents - step) % 26
cryptText.append(decrypt)
newLetter = caps[decrypt]
outText.append(newLetter)
elif letter in nocaps:
contents = nocaps.index(letter)
decrypt = (contents - step) % 26
cryptText.append(decrypt)
newLetter = nocaps[decrypt]
outText.append(newLetter)
return outText
letters = int(configParser.get('letters', 'l'))
word = configParser.get('letters', 'output')
output = decrypt(word, letters)
aoutput = str(output).replace(",", "")
aaoutput = str(aoutput).replace("'", "")
print("-------------------------")
print(aaoutput)
print("-------------------------")