summaryrefslogtreecommitdiffstats
path: root/tests
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 /tests
parent7312ac25a4a89c603cc8311f442a000433b5301b (diff)
downloadmatasano-ef018a85888a2d77b0dc4904404776ae1b6cb401.tar.gz
matasano-ef018a85888a2d77b0dc4904404776ae1b6cb401.zip
make these functions more useful
Diffstat (limited to 'tests')
-rw-r--r--tests/lib.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/lib.rs b/tests/lib.rs
index 0003696..3615b3c 100644
--- a/tests/lib.rs
+++ b/tests/lib.rs
@@ -1,16 +1,19 @@
extern crate matasano;
+extern crate "rustc-serialize" as serialize;
+
+use serialize::hex::FromHex;
#[test]
fn problem_1 () {
let hex = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
let base64 = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t";
- assert_eq!(matasano::hex_to_base64(hex), base64);
+ assert_eq!(matasano::to_base64(&hex.from_hex().unwrap()[..]), base64);
}
#[test]
fn problem_2 () {
- let str1 = "1c0111001f010100061a024b53535009181c";
- let str2 = "686974207468652062756c6c277320657965";
- let expected = "746865206b696420646f6e277420706c6179";
- assert_eq!(matasano::fixed_xor(str1, str2), expected);
+ let bytes1 = "1c0111001f010100061a024b53535009181c".from_hex().unwrap();
+ let bytes2 = "686974207468652062756c6c277320657965".from_hex().unwrap();
+ let expected = "746865206b696420646f6e277420706c6179".from_hex().unwrap();
+ assert_eq!(matasano::fixed_xor(&bytes1[..], &bytes2[..]), expected);
}