python 使用异或对数字进行加密

Posted on Posted in python

python 使用异或对数字进行加密

异或的性质

  • 相同的两个数,相异或以后结果为0
  • 0与任何数相异或,结果仍然是原来的数字
  • 异或操作满足交换率
In [1]: qq = 88888888
In [2]: passwd = 7777 
In [3]: cipher = qq ^ passwd # 加密
n [4]: cipher                                                                                                                                                                        
Out[4]: 88885337
In [5]: cipher ^ qq  # 解密                                                                                                                                     
Out[5]: 7777

转 https://mp.weixin.qq.com/s/EujP-kjcXNZzfLSWRv2_ww

» 转载请注明来源:呢喃 » python 使用异或对数字进行加密

Leave a Reply

Your email address will not be published. Required fields are marked *

one + 8 =