Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use failure::Error;
- use std::str;
- fn bytes_from_hex_str(hex: &str) -> Result<Vec<u8>, Error> {
- let mut bytes = vec![];
- for i in (0..hex.len()).step_by(2) {
- let byte = u8::from_str_radix(&hex[i..=(i + 1)], 16)?;
- bytes.push(byte);
- }
- Ok(bytes)
- }
- fn main() {
- let s = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736".to_string();
- let bytes = bytes_from_hex_str(&s).expect("must work");
- for c in (b'a'..b'z').chain(b'0'..b'9').chain(b'A'..b'Z') {
- let phrase = bytes.iter().map(|&b| b ^ c).collect::<Vec<_>>();
- println!("{} - {}", c, str::from_utf8(&phrase).unwrap());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement