I'm currently working on a program that both encrypts and decrypts code. I have three options in the menu that the user can choose, Encrypt, Decrypt or Extended Encrypt. I am having a problem with the extended encrypt.
Basically, to make the ciphertext harder for another person to decrypt, I would like to group it into groups of five letters, one way I thought of doing this was to put the base encrypted text into a string and go through every index and checking if it was divisible by five with a remainder of zero (modulo):
extend = ""
for x in range(0, len(encrypted)): #encrypted would have its contents defined before hand
if x % 5 == 0:
extend = extend + " " #adds a space, could otherwise do + chr(32)
else:
extend = extend + encrypted[x]
When look at the outputted file, the file contains no extra spaces, its as though x % 5 never has a value of zero, so the line extend = extend + " " is never called.
Thanks in advance!