solve Challenge 1 of Set 1
commit
72a40f5ad9
|
@ -0,0 +1 @@
|
||||||
|
*/*/target
|
|
@ -0,0 +1,12 @@
|
||||||
|
[root]
|
||||||
|
name = "hex2base64"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-serialize"
|
||||||
|
version = "0.3.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "hex2base64"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Thomas Lindner <thomas.lindner@fau.de>"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
rustc-serialize = "0.3"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "hex2base64"
|
||||||
|
path = "src/bin.rs"
|
|
@ -0,0 +1,15 @@
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue