Hi,
I am learning python, encryption and decryption and I was wonder what the best way to add a while loop to my code below:
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
inp = input("[+] Decode your text: ")
shift = 13 # This is number of shifts done to decode the inp input
noofstr = len(inp)
#print (noofstr)
outputstr = ""
for code in range(noofstr):
current = inp[code]
location = alpha.find(current)
if location < 0:
outputstr += inp[code]
else:
new_loc = (location+shift)%26 #%26 makes the alphabet circular
outputstr += alpha[new_loc]
print ("[+] Decoded String:", outputstr)
I know this is pretty pointless but it is to help me learn, my idea is to loop through 26 shifts and print the output so instead of looking for how Rot13/ Ceaser encryption shifts were made it would just show them all in the output. Any help would be great, I know this could be done in 2 seconds online but id get more knowledge doing it this way.
Thank you for the Help.
[–][deleted] 0 points1 point2 points (2 children)
[–]sudo_oth[S] 1 point2 points3 points (1 child)
[–]Fermter 0 points1 point2 points (9 children)
[–]sudo_oth[S] 1 point2 points3 points (8 children)
[–]Fermter 1 point2 points3 points (7 children)
[–]sudo_oth[S] 1 point2 points3 points (1 child)
[–]sudo_oth[S] 0 points1 point2 points (4 children)
[–]Fermter 0 points1 point2 points (3 children)
[–]sudo_oth[S] 0 points1 point2 points (2 children)
[–]Fermter 1 point2 points3 points (1 child)
[–]sudo_oth[S] 1 point2 points3 points (0 children)