So this is a little bit of code that used to work on it's own, but when i tried to implement it into my code it gave me an error, i think it's because i mutated the bits inside of s2 is there any other way to XOR s3 without binascii.a2b_qp
def xor(s1,s2):
s3 =''.join(chr(i^j) for i,j in zip(s1,s2))
s4 = binascii.a2b_qp(s3)
s5 = ''.join(chr(i^j) for i,j in zip(s2,s4))
print(s5)
# for testing:
# additional info, s1 is a mutated form of bits from s2 using an S box
s1 = b'\xc3\xbf\x00\x00\xc3\xbf\x00\xc3\xbf\x00\x00'
s2 = b'aaaaaaaa'
xor(s1, s2)
Traceback:
Traceback (most recent call last):
File "C:\Users\Pavilion g7\workspace\Python Network\RW.py", line 138, in <module>
x= xor(m1,m2)
File "C:\Users\Pavilion g7\workspace\Python Network\RW.py", line 69, in xor
s4 = binascii.a2b_qp(s3)
ValueError: string argument should contain only ASCII characters