solve Challenge 1 of Set 1
This commit is contained in:
commit
72a40f5ad9
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*/*/target
|
12
set1/hex2base64/Cargo.lock
generated
Normal file
12
set1/hex2base64/Cargo.lock
generated
Normal file
|
@ -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"
|
||||
|
11
set1/hex2base64/Cargo.toml
Normal file
11
set1/hex2base64/Cargo.toml
Normal file
|
@ -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"
|
15
set1/hex2base64/src/bin.rs
Normal file
15
set1/hex2base64/src/bin.rs
Normal file
|
@ -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 a new issue