Quote:
Originally Posted by daveT
(to get the same result as ChrisV, you need to enter 23).
daveT,
That's interesting and strange. I don't understand why 23 is the value to successfully decrypt the cipher text instead of 3. How would I modify it to make it so a shift value of 3 successfully decrypts? I'm required to have 3 be the decrypting shift value.
Also, the assignment was originally instructed to be done in Java, and in the example my professor went over converting to ASCII in Java, but he also said we could use Python. I've tried running this code in Python3 after fixing the print syntax at the bottom and it fails with this error message. Any ideas?
Code:
cipherText = "FRQJUDWXODWLRKVBRXKDYHGHFOBSWHGWKHPHVVDJH"
shiftValue = input("Please enter an integer shift value from 1 to 26: ")
result = ""
for char in cipherText:
result = result + chr(((ord(char) - 65 - shiftValue) % 26) + 65)
print(result)
Quote:
Traceback (most recent call last):
File "C:\Users\IDC\Documents\Cryptography\CasesarCipher \TestFile.py", line 6, in <module>
result = result + chr(((ord(char) - 65 - shiftValue) % 26) + 65)
TypeError: unsupported operand type(s) for -: 'int' and 'str'
I have no idea what this means. And as an aside, I don't even want to ask what endianness is. I'm astounded at how easy some of you make programming look. It's tough in my opinion.