Cesar密码
cesar-cipher的Python项目详细描述
塞萨尔密码
安装
$ pip install cesar_cipher
用法
fromcesar_cipherimportcscs.cesar(msg,cmd,key=3)# where:# * 'msg' is the message/char to be encrypt/decrypt# (special digits are ignored)# * 'cmd' is the command to define the operation# ('e' to encrypt and 'd' to decrypt)# * 'key' is optional (default 3) key to encrypt/decrypt
示例
>>>from cesar_cipher import cs >>># Encrypting the letter 'a' with default key (3) >>>print(cs.cesar('a', 'e'))'d' >>># Decrypting the letter 'd' with default key (3) >>>print(cs.cesar('d', 'd'))'a' >>># Encrypting the string 'abc' with default key (3) >>>print(cs.cesar('ABC', 'e'))'DEF'