0
我必須使用Caesar Cipher加密用戶提供的明文。將每個純文本字符轉換爲其ASCII(整數)值並存儲在列表中。 我曾經做過這樣的Python中的凱撒密碼(意外錯誤)
print("This program uses a Caesar Cipher to encrypt a plaintext message using the encryption key you provide.")
plaintext = input("Enter the message to be encrypted:")
plaintext = plaintext.upper()
n = eval(input("Enter an integer for an encrytion key:"))
ascii_list = []
# encipher
ciphertext = ""
for x in range(len(plaintext)):
ascii_list[x] = plaintext (ascii_list) + n %26
print()
但是像這樣出現錯誤:
TypeError: 'str' object is not callable
我想要的結果出來:
This program uses a Caesar Cipher to encrypt a plaintext message using the encryption key you provide.
Enter the message to be encrypted: Boiler Up Baby!
Enter an integer for an encrytion key: 1868
The fully encoded message is: CWOTFZ&]QCHICa'
我已經嘗試了很多不同的方式,但結果不出來。
你期望'純文本(ascii_list)'做什麼? –