发布网友 发布时间:2022-04-23 08:50
共1个回答
热心网友 时间:2022-05-11 02:28
摘要我知道有一个内置的xor运算符可以用Python导入.我正在尝试执行xor加密/解密到目前为止我有:def xor_attmpt():message=raw_input("Enter message to be ciphered:")cipher=[]for i in message:cipherappend(bin(ord(i))[2:])#add the conversion of the letters/characters#in your message from ascii to binarywithoout the Ob in the front to your ciphered message listcipher=""join(cipher)privvyKey=raw_input("Enter the private key")keydecrypt=[]for jin pri?vvyKey:keydecrypt.append(bin(ord(j))[2::])#samekeydecrypt="".join(keydecrypt )#sameprint "key is '{0}"" .format(keydecrypt)#substitute values in stringprint "encrypted text is '{0}"" .format(cipher)from operator import xorfor letter in messageprint xor(bool(cipher),bool(keydecrypt))这个:> for letter in message:print xor(bool(cipher),bool(keydecrypt))是我的python开始出错的地方输出看起来像这样Enter message to be ciphered: helloEnter the private key:\@154>key is10111001000000110001110101110100111110'encrypted text is11010001100101110110011011001101111FalseFalseFalseFalseFalse咨询记录 · 回答于2021-12-08python程序使用+key+作为参数,对给定的文本文件执行加密运算,加密后的文件https://nbic7r11u.pxvqgzr.com/f/Y2VXqX9C1 上,栲贝该椴,点开筷守我知道有一个内置的xor运算符可以用Python导入.我正在尝试执行xor加密/解密到目前为止我有:def xor_attmpt():message=raw_input("Enter message to be ciphered:")cipher=[]for i in message:cipherappend(bin(ord(i))[2:])#add the conversion of the letters/characters#in your message from ascii to binarywithoout the Ob in the front to your ciphered message listcipher=""join(cipher)privvyKey=raw_input("Enter the private key")keydecrypt=[]for jin pri?vvyKey:keydecrypt.append(bin(ord(j))[2::])#samekeydecrypt="".join(keydecrypt )#sameprint "key is '{0}"" .format(keydecrypt)#substitute values in stringprint "encrypted text is '{0}"" .format(cipher)from operator import xorfor letter in messageprint xor(bool(cipher),bool(keydecrypt))这个:> for letter in message:print xor(bool(cipher),bool(keydecrypt))是我的python开始出错的地方输出看起来像这样Enter message to be ciphered: helloEnter the private key:\@154>key is10111001000000110001110101110100111110'encrypted text is11010001100101110110011011001101111FalseFalseFalseFalseFalse