// XOR two fixed length hex strings together
XOR two fixed length hex strings together
XOR two fixed length hex strings together
pub fn hex_fixed_xor(in1: &str, in2: &str) -> String {
	let in1_bytes: Vec<u8> = hex::decode(in1.to_string())
		.expect("Failed to decode the first input hex string");
	let in2_bytes: Vec<u8> = hex::decode(in2.to_string())
		.expect("Failed to decode the second input hex string");
	if in1_bytes.len() != in2_bytes.len() {
		panic!("The decoded hex strings are of uneven lenghts and cannot be XOR-ed against each other");
	}
	let xored: Vec<u8> = in1_bytes
		.iter()
		.zip(in2_bytes.iter())
		.map(|(&b1,&b2)| b1^b2)
		.collect();
	hex::encode(&xored)
}
pub fn hex_fixed_xor ( in1 : & str , in2 : & str ) -> String { let in1_bytes : Vec < u8 > = hex :: decode ( in1 . to_string ( ) ) . expect ( " " ) ; let in2_bytes : Vec < u8 > = hex :: decode ( in2 . to_string ( ) ) . expect ( " " ) ; if in1_bytes . len ( ) != in2_bytes . len ( ) { panic ! ( " " ) ; } let xored : Vec < u8 > = in1_bytes . iter ( ) . zip ( in2_bytes . iter ( ) ) . map ( | ( & b1 , & b2 ) | b1 ^ b2 ) . collect ( ) ; hex :: encode ( & xored ) }
XOR two fixed length hex strings together
XOR two fixed length hex strings together
in1
&str
in2
&str