带有随机键和空格的凯撒密码代码问题

时间:2018-11-26 01:54:57

标签: python

def message():
    answer = input('Welcome to the Caesar Cipher! What do you want to encrypt?')
    key = input('Enter the key number that you want to encrypt with. (1 - 25)')
    return answer, int(key)


def getMessage(answer, key):
    lengthList = []
    leng = 0
    while leng < len(answer):
        lengthList.append(chr(ord(answer[leng]) + key))
        leng += 1
    print("By the way, random keys are spaces.")
    print("".join(lengthList))


answer, key = message()
getMessage(answer, key)

这是我的Caesar Cipher Encryption Only代码,而我的问题是,有时当我输入消息时,某些字母会变成不同的符号,而不是字母。如何使打印的消息仅包含密钥?我还需要帮助,如果有空格,它也会变成另一个符号。您还如何使这些空间成为空间?

0 个答案:

没有答案