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:
|
if cipherFile is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
#for lines in cipherFile:
|
letterAToAscii = ord('A') # Get the ASCII code
|
||||||
# splitLines = lines.split(' ')
|
letterZToAscii = ord('Z') # Get the ASCII code
|
||||||
|
letteraToAscii = ord('a') # Get the ASCII code
|
||||||
# for word in splitLines:
|
letterzToAscii = ord('z') # Get the ASCII code
|
||||||
# if len(word) <= 3:
|
for key in range (0, 26):
|
||||||
# print(word)
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
AJGNNQ YQTNF!
|
JGNNQ YQTNF!
|
||||||
LG UWKU WP OGUUCIG GP ENCKT !!
|
LG UWKU WP OGUUCIG GP ENCKT !!
|
||||||
|
Loading…
Reference in New Issue
Block a user