#!/bin/python import sys, getopt, os def main(argv): comp1 = '' comp2 = '' comp3 = '' try: opts, args = getopt.getopt(argv,"hc1:c2:c3:",["comp1=","comp2=","comp3="]) except getopt.GetoptError: print ('test.py -i -a
-p ') sys.exit(2) for opt, arg in opts: if opt == '-h': print ('test.py -i -a
-p ') sys.exit() elif opt in ("-c1","--comp1"): comp1 = str(arg) elif opt in ("-c2","--comp2"): comp2 = str(arg) elif opt in ("-c3","--comp3"): comp3 = str(arg) if len(comp1) != len(comp2) or len(comp1) != len(comp3): print("All components should be of the same length") sys.exit(2) if len(comp1) not in (16, 32, 64, 128, 256): print("All components should be of byte length") 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() for c,d,f in zip(bytes1,bytes2,bytes3): e.append( ( c ^ d ^ f ) ) print(e.hex()) if __name__ == "__main__": main(sys.argv[1:])