首页 > 代码库 > Python_字符串简单加密解密
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_字符串简单加密解密
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。