Skip to content

Instantly share code, notes, and snippets.

@dlwhitehurst
Created July 13, 2016 02:35
Show Gist options
  • Save dlwhitehurst/70d1ce17b18bda890fdc523c7c6be274 to your computer and use it in GitHub Desktop.
Save dlwhitehurst/70d1ce17b18bda890fdc523c7c6be274 to your computer and use it in GitHub Desktop.
extern crate rustc_serialize;
use rustc_serialize::hex::{FromHex,ToHex};
fn main() {
let hex_str = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736";
let a = "88888888888888888888888888888888888888888888888888888888888888888888";
let result = xor(hex_str,a);
println!("{:?}",result);
}
/*
This function does an exclusive or operation on two hexadecimal strings
*/
pub fn xor(a: &str, b: &str) -> Vec<u8> {
return a.from_hex().unwrap().iter().zip(b.from_hex().unwrap().iter()).map(|(&x,&y)|x^y).collect();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment