Python_字符串简单加密解密 1def crypt(source,key):
2from itertools import cycle
3    result=''
4    temp=cycle(key)
5for ch in source:
6        result=result+chr(ord(ch)^ord(next(temp)))
密码字符串是什么7return result
8
9 source='Jiangxi Insstitute of Busiess and Technology'
10 key='zWrite'
11
12print('Before Encrypted:'+source)
13 encrypted=crypt(source,key)
14print('After Encrypted:'+encrypted)
15 decrypted=crypt(encrypted,key)
16print('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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。