I have a cipher called sortedcipher. And what I whats is to group 2 characters at once. At his point I have this code:
def Decrypt_Final():
sortedcipher = "AVGFGAFFGFGFFAAAFGAVGAGAFFAAFAGFDFGDFFDXDFFDAGAAX"
Mensagem_Original = ""
i = 0
while (i < (len(sortedcipher))):
value = sortedcipher[i] + sortedcipher[i+1]
for key in keysquare:
if value in (keysquare[key]):
Mensagem_Original += key
i += 2
value = ""
return Mensagem_Original
Whats is doing is : "AV","GF"........"AA","X" and when it reach the end just gets the "X" instead of double letter because it cant do more sortedcipher[i+1].
How can I do a condition to stop do it when it reaches something like this?