Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn encode_hex(bytes: &Vec<u8>) -> Result<String, &str> {
- let x = bytes
- .iter()
- .map(|digit| {
- match (
- std::char::from_digit((digit / 16) as u32, 16),
- std::char::from_digit((digit % 16) as u32, 16),
- ) {
- (Some(x), Some(y)) => Ok(vec![x, y]),
- _ => Err("Could not convert digit"),
- }
- })
- .collect::<Result<Vec<Vec<char>>, &str>>()?
- .iter()
- .flatten()
- .collect::<String>();
- Ok(x.clone())
- }
- fn main() {
- let mut cyphertext: Vec<u8> = unimplemented!();
- cyphertext.truncate(cyphertext.len() - 16);
- cyphertext.reverse();
- println!("reduce {:?}", cyphertext);
- let plaintext: Vec<u8> = vec![];
- let s = encode_hex(&cyphertext).unwrap();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement