summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2015-03-15 04:58:29 -0400
committerJesse Luehrs <doy@tozt.net>2015-03-15 04:58:29 -0400
commitef018a85888a2d77b0dc4904404776ae1b6cb401 (patch)
treeeff36cb5c25802c322eb6510850106cc5d655539 /src/lib.rs
parent7312ac25a4a89c603cc8311f442a000433b5301b (diff)
downloadmatasano-ef018a85888a2d77b0dc4904404776ae1b6cb401.tar.gz
matasano-ef018a85888a2d77b0dc4904404776ae1b6cb401.zip
make these functions more useful
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f2e1508..764fea2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,19 +1,14 @@
extern crate "rustc-serialize" as serialize;
use serialize::base64::{ToBase64,STANDARD};
-use serialize::hex::{FromHex,ToHex};
-pub fn hex_to_base64 (hex: &str) -> String {
- let bytes = hex.from_hex().unwrap();
+pub fn to_base64 (bytes: &[u8]) -> String {
return bytes.to_base64(STANDARD);
}
-pub fn fixed_xor (str1: &str, str2: &str) -> String {
- let bytes1 = str1.from_hex().unwrap();
- let bytes2 = str2.from_hex().unwrap();
+pub fn fixed_xor (bytes1: &[u8], bytes2: &[u8]) -> Vec<u8> {
return bytes1.iter()
.zip(bytes2.iter())
.map(|(&a, &b)| { a ^ b })
- .collect::<Vec<u8>>()
- .to_hex();
+ .collect();
}