到目前为止,这就是我的 Caeser Cipher 程序。
import string
character = []
message = raw_input('What is your message? ').lower()
shift = raw_input('What is your shift key? ')
code = raw_input('Would you like to cipher(c) or decipher(d)? ')
if str(code) == 'd':
for character in message:
number = ord(character) - int(shift)
if number <= 96:
number = ord(character) + 26 - int(shift)
character = chr(number)
elif str(code) == 'c':
for character in message:
number = ord(character) + int (shift)
if number >= 123:
number = ord(character) - 26 + int(shift)
character = chr(number)
print(str(character))
每次我使用这个程序时,我都会返回我为消息键入的行的最后一个字母的加密或解密消息。我不确定如何打印出我的整个加密或解密消息。