How to XOR a byte output?

durgadevi1 srirajarajeswaridevikrupa at gmail.com
Thu Apr 14 04:49:49 EDT 2016


> 
> This looks clearer:
> 
>    >>> code = b'a0\xed\xf0Z\x15]g^\xce3x'
>    >>> key = b')U\x81\x9c55*\x08,\xa2WY'
>    >>> bytes(c ^ k for c, k in zip(code, key)).decode()
>    'Hello world!'
> 
> 
> Marko

Hi, I have gotten another error message when working with the bytes(c ^ k for c, k in zip(code, key)).decode().

Here is the error.
 print(bytes(c ^ k for c, k in zip(CODE, key)).decode())
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 0: invalid start byte

What I did is XOR the CODE with a certain value before using the

bytes(c ^ k for c, k in zip(CODE, key)).decode() code.

However, I get no errors when using values 0 to 127 to XOR with CODE. But I get errors when using values (128 to 255). May I know how I can modify the program code so that i can XOR with values (128 to 255)?
 




More information about the Python-list mailing list