def encrypt(text): first_encryption = "" second_encryption = "" for char in text: if char.isalpha(): first_encryption += str(ord(char.lower()) - 96).zfill(2) elif char.isdigit(): first_encryption += str(int(char) + 26) elif char == " ": first_encryption += "2"

for char in first_encryption:
    if char.isdigit():
        second_encryption += str(int(char) + 26)
    elif char == " ":
        second_encryption += "00"

return second_encryption

plaintext = input("请输入一段明文: ") ciphertext = encrypt(plaintext) print("对应密文为:", ciphertext)

有这样一种加密的策略 第一次加密策略是将明文中字母 a 加密为 01b 加密为 02c 加密为03以此类推X加密为 24y 加密为 25加密为 2空格不加密然后在第一次加密的基础上进行二次加密第二次加密策略是将数字0加密为 27数字 1加密为 28以此类推数字 8加为 35数字9加密36空格则加密为 00。编程实现 请输入一段明文按照上述加密策略输出对应密文。用py

原文地址: http://www.cveoy.top/t/topic/ja6c 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录