Update code
This commit is contained in:
parent
c9b432c900
commit
d43947e51f
31
main.py
31
main.py
@ -63,13 +63,30 @@ def decryptCaesarText(cipherFile):
|
||||
if cipherFile is None:
|
||||
return
|
||||
|
||||
#for lines in cipherFile:
|
||||
# splitLines = lines.split(' ')
|
||||
|
||||
# for word in splitLines:
|
||||
# if len(word) <= 3:
|
||||
# print(word)
|
||||
|
||||
letterAToAscii = ord('A') # Get the ASCII code
|
||||
letterZToAscii = ord('Z') # Get the ASCII code
|
||||
letteraToAscii = ord('a') # Get the ASCII code
|
||||
letterzToAscii = ord('z') # Get the ASCII code
|
||||
for key in range (0, 26):
|
||||
foo = []
|
||||
for line in cipherFile:
|
||||
newLine = str()
|
||||
for letter in line:
|
||||
letter = letter.upper()
|
||||
l = ord(letter)
|
||||
if l >= letterAToAscii and l <= letterZToAscii:
|
||||
l = l - letterAToAscii
|
||||
res = ((l - key) % 26) + letterAToAscii
|
||||
newLine = newLine + chr(res)
|
||||
elif l >= letteraToAscii and l <= letterzToAscii:
|
||||
l = l - letteraToAscii
|
||||
res = ((l - key) % 26) + letteraToAscii
|
||||
newLine = newLine + chr(res)
|
||||
else:
|
||||
newLine = newLine + letter
|
||||
foo.append(newLine)
|
||||
print(f"key: {key}")
|
||||
print(foo)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -1,2 +1,2 @@
|
||||
AJGNNQ YQTNF!
|
||||
JGNNQ YQTNF!
|
||||
LG UWKU WP OGUUCIG GP ENCKT !!
|
||||
|
Loading…
Reference in New Issue
Block a user