summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
blob: 0a64486f53fc572bc7dd8b96753197310f82e504 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
extern crate "rustc-serialize" as serialize;

use serialize::base64::{ToBase64,STANDARD};
use serialize::hex::FromHex;

pub fn hex_to_base64 (hex: &str) -> String {
    let bytes = match hex.from_hex() {
        Ok(b) => b,
        Err(e) => panic!("{}", e),
    };
    return bytes.to_base64(STANDARD);
}