xor added
This commit is contained in:
+7
-23
@@ -27,29 +27,13 @@ def main(argv):
|
|||||||
print("All components should be of byte length")
|
print("All components should be of byte length")
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
bytes1 = bytes.fromhex( comp1.encode("utf-8").hex())
|
||||||
|
bytes2 = bytes.fromhex( comp2.encode("utf-8").hex())
|
||||||
|
bytes3 = bytes.fromhex( comp3.encode("utf-8").hex())
|
||||||
|
e = bytearray()
|
||||||
>>> a = "a133efb38766"
|
for c,d,f in zip(bytes1,bytes2,bytes3):
|
||||||
>>> b = "a0a1a2a3a5a7"
|
e.append( ( c ^ d ^ f ) )
|
||||||
>>> a.encode().hex()
|
print(e.hex())
|
||||||
'613133336566623338373636'
|
|
||||||
>>> bytes1 =
|
|
||||||
|
|
||||||
|
|
||||||
>>> bytes2 = bytes.fromhex( b.encode("utf-8").hex())
|
|
||||||
>>> xored = bytes( b1 ^ b2 for b1,b2 in zip(bytes1,bytes2))
|
|
||||||
>>> xored.hex()
|
|
||||||
'000152020454030059025701'
|
|
||||||
|
|
||||||
>>> for c,d in zip(bytes1,bytes2):
|
|
||||||
... e.append( ( c ^ d ) )
|
|
||||||
...
|
|
||||||
>>> e
|
|
||||||
bytearray(b'\x00\x01R\x02\x04T\x03\x00Y\x02W\x01')
|
|
||||||
>>> e.hex()
|
|
||||||
'000152020454030059025701'
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user