// XOR input hex string with every character and output the most likely key and result based on character scores
XOR input hex string with every character and output the most likely key and result based on character scores
XOR input hex string with every character and output the most likely key and result based on character scores
pub fn single_bit_xor_cypher(ct: &str) -> (char, String) {
	use std::str::from_utf8;
	// Convert hex string to bytes
	let ct_bytes: Vec<u8> = hex::decode(ct.to_string())
		.expect("Failed to decode the first input hex string");
	// Find the key that maximises the score by XOR-ing the ciphertext with all possible keys (i.e., u8 range)
	let max_score_key: u8 = (0..=255)
		.max_by_key(|&key| vector_score(&key_xor(&ct_bytes, key)))
		.unwrap();
	// Return the plaintext key and plaintext
	(max_score_key as char,from_utf8(&key_xor(&ct_bytes, max_score_key))
		.expect("Failed to get String from vector")
		.to_string())
}
pub fn single_bit_xor_cypher ( ct : & str ) -> ( char , String ) { use std :: str :: from_utf8 ; // Convert hex string to bytes let ct_bytes : Vec < u8 > = hex :: decode ( ct . to_string ( ) ) . expect ( " " ) ; // Find the key that maximises the score by XOR-ing the ciphertext with all possible keys (i.e., u8 range) let max_score_key : u8 = ( 0 ..= 255 ) . max_by_key ( | & key | vector_score ( & key_xor ( & ct_bytes , key ) ) ) . unwrap ( ) ; // Return the plaintext key and plaintext ( max_score_key as char , from_utf8 ( & key_xor ( & ct_bytes , max_score_key ) ) . expect ( " " ) . to_string ( ) ) }
XOR input hex string with every character and output the most likely key and result based on character scores
XOR input hex string with every character and output the most likely key and result based on character scores
ct
&str