首页 > 编程语言 > 详细

Python_字符串简单加密解密

时间:2017-06-08 14:33:07      阅读:613      评论:0      收藏:0      [点我收藏+]
 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_字符串简单加密解密

原文:http://www.cnblogs.com/cmnz/p/6962500.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!