Python_字符串简单加密解密

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python_字符串简单加密解密相关的知识,希望对你有一定的参考价值。

 1 def crypt(source,key):
 2     from itertools import cycle
 3     result=‘‘
 4     temp=cycle(key)
 5     for ch in source:
 6         result=result+chr(ord(ch)^ord(next(temp)))
 7     return result
 8 
 9 source=Jiangxi Insstitute of Busiess and Technology
10 key=zWrite
11 
12 print(Before Encrypted:+source)
13 encrypted=crypt(source,key)
14 print(After Encrypted:+encrypted)
15 decrypted=crypt(encrypted,key)
16 print(After Decrypted:+decrypted)
17 # Before Encrypted:Jiangxi Insstitute of Busiess and Technology
18 # After Encrypted:0>w;>Z8I6    >E9I ?
19 # .
20 # After Decrypted:Jiangxi Insstitute of Busiess and Technology

 

以上是关于Python_字符串简单加密解密的主要内容,如果未能解决你的问题,请参考以下文章

Python中hashlib模块

解密在 PHP 中使用 MCRYPT_RIJNDAEL_256 加密的 Python 字符串

hashlib加密模块_python

python 用于在终端中运行的sublime text 3的简单代码片段制作工具

怎么样给python文件加密

Python--加密小练习