Skip to content

Instantly share code, notes, and snippets.

@aminyuddin
Created June 23, 2023 09:55
Show Gist options
  • Select an option

  • Save aminyuddin/d7fec56de66181a9a26ce05f5da2e945 to your computer and use it in GitHub Desktop.

Select an option

Save aminyuddin/d7fec56de66181a9a26ce05f5da2e945 to your computer and use it in GitHub Desktop.
def combine_zpk_clear_components(component1, component2):
combined_key_bytes = bytearray(len(component1))
for i in range(len(combined_key_bytes)):
combined_key_bytes[i] = component1[i] ^ component2[i]
return combined_key_bytes
def hex_string_to_byte_array(hex_string):
length = len(hex_string)
byte_array = bytearray(length // 2)
for i in range(0, length, 2):
byte_array[i // 2] = int(hex_string[i:i + 2], 16)
return byte_array
def byte_array_to_hex_string(byte_array):
hex_string = ""
for b in byte_array:
hex_string += format(b, '02X')
return hex_string
def main():
zpk_component1 = "XXX"
zpk_component2 = "YYY"
try:
zpk_component1_bytes = hex_string_to_byte_array(zpk_component1)
zpk_component2_bytes = hex_string_to_byte_array(zpk_component2)
combined_bytes = combine_zpk_clear_components(zpk_component1_bytes, zpk_component2_bytes)
combined_zpk = byte_array_to_hex_string(combined_bytes)
print("Combined ZPK:", combined_zpk)
except Exception as e:
print("Error:", e)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment