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

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

pub fn to_base64 (bytes: &[u8]) -> String {
    return bytes.to_base64(STANDARD);
}

pub fn fixed_xor (bytes1: &[u8], bytes2: &[u8]) -> Vec<u8> {
    return bytes1.iter()
        .zip(bytes2.iter())
        .map(|(&a, &b)| { a ^ b })
        .collect();
}