Python实现移位密码(凯撒密码)加密

标签:
pythonit |
分类: 软件开发 |
Python实现移位密码(凯撒密码)加密
凯撒密码(Caesar 密码)是最早的代换密码,也是古典对称密码体制的典型代表,已经初
步体现出近代密码系统的雏形。其算法是:将每个字母用字母表中它之后的第k 个字母(称
作位移值)替代。例如:
明文:meet me after the toga party
密文:phhw ph diwhu wkh wrjd sduwb
(k=3)
作位移值)替代。例如:
明文:meet me after the toga party
密文:phhw ph diwhu wkh wrjd sduwb
(k=3)
from string import *
def Caesar_cipher(text, shift):
print Caesar_cipher('asdfDERW12,asdffdK:JKJ:liowe', 3)