cryptopals-rust/set1/hex2base64/src/bin.rs

16 lines
398 B
Rust

extern crate rustc_serialize;
use rustc_serialize::hex::FromHex;
use rustc_serialize::base64::{STANDARD, ToBase64};
use std::io::{BufRead, stdin};
fn main() {
let stdin = stdin();
for line in stdin.lock().lines().filter_map(|x| x.ok()) {
match line.from_hex() {
Ok(v) => println!("{}", v.to_base64(STANDARD)),
Err(e) => println!("{}", e)
}
}
}