反向密码程序的Python实现与原理剖析
1. 反向密码程序的源代码与运行
在IDLE中,点击 File -> New Window 创建一个新的文件编辑窗口。输入以下代码,将其保存为 reverseCipher.py ,然后按 F5 运行,但不要输入每行前面的数字:
# Reverse Cipher
# https://www.nostarch.com/crackingcodes/ (BSD Licensed)
message = 'Three can keep a secret, if two of them are dead.'
translated = ''
i = len(message) - 1
while i >= 0:
translated = translated + message[i]
i = i - 1
print(translated)
运行 reverseCipher.py 程序时,输出如下:
.daed era meht fo owt fi ,terces a peek nac eerhT
若要解密此消息,可按以下步骤操作:
1. 在Windows和Linux系统上,通过高亮显示消息并按 ctrl - C ;在macOS系统上按 ⌘ - C ,将
超级会员免费看
订阅专栏 解锁全文
2793

被折叠的 条评论
为什么被折叠?



