diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/base64.rs | 5 | ||||
-rw-r--r-- | src/lib.rs | 3 | ||||
-rw-r--r-- | src/md4.rs | 5 | ||||
-rw-r--r-- | src/primitives.rs | 4 | ||||
-rw-r--r-- | src/sha1.rs | 17 |
5 files changed, 17 insertions, 17 deletions
diff --git a/src/base64.rs b/src/base64.rs deleted file mode 100644 index 9b01da8..0000000 --- a/src/base64.rs +++ /dev/null @@ -1,5 +0,0 @@ -use rustc_serialize::base64::{ToBase64, STANDARD}; - -pub fn to_base64(bytes: &[u8]) -> String { - return bytes.to_base64(STANDARD); -} @@ -1,5 +1,4 @@ mod aes; -mod base64; mod crack; mod data; mod http; @@ -14,7 +13,6 @@ pub use aes::decrypt_aes_128_cbc; pub use aes::decrypt_aes_128_ecb; pub use aes::encrypt_aes_128_cbc; pub use aes::encrypt_aes_128_ecb; -pub use base64::to_base64; pub use crack::clone_mersenne_twister_from_output; pub use crack::crack_aes_128_ctr_random_access; pub use crack::crack_cbc_bitflipping; @@ -46,6 +44,7 @@ pub use md4::pad_md4; pub use primitives::fixed_xor; pub use primitives::pad_pkcs7; pub use primitives::repeating_key_xor; +pub use primitives::to_base64; pub use primitives::unpad_pkcs7; pub use random::mt19937_stream_cipher; pub use random::MersenneTwister; @@ -1,6 +1,3 @@ -#[cfg(test)] -use rustc_serialize::hex::ToHex; - pub fn md4(bytes: &[u8]) -> [u8; 16] { md4_with_state( bytes, @@ -185,7 +182,7 @@ fn test_md4() { ]; for &(input, expected) in tests.iter() { println!("{:?}", input); - let got = &md4(input)[..].to_hex(); + let got = hex::encode(&md4(input)[..]); assert_eq!(got, expected); } } diff --git a/src/primitives.rs b/src/primitives.rs index 6f178cc..a93f83c 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -1,3 +1,7 @@ +pub fn to_base64(bytes: &[u8]) -> String { + return base64::encode(bytes); +} + pub fn fixed_xor(bytes1: &[u8], bytes2: &[u8]) -> Vec<u8> { return bytes1 .iter() diff --git a/src/sha1.rs b/src/sha1.rs index 7969b21..6b76a3f 100644 --- a/src/sha1.rs +++ b/src/sha1.rs @@ -1,6 +1,3 @@ -#[cfg(test)] -use rustc_serialize::hex::ToHex; - use crate::primitives::fixed_xor; pub fn sha1(bytes: &[u8]) -> [u8; 20] { @@ -138,7 +135,7 @@ fn test_sha1() { ), ]; for &(input, expected) in tests.iter() { - let got = &sha1(input)[..].to_hex(); + let got = hex::encode(&sha1(input)[..]); assert_eq!(got, expected); } } @@ -146,8 +143,16 @@ fn test_sha1() { #[test] fn test_sha1_hmac() { assert_eq!( - &sha1_hmac(b"", b"")[..].to_hex(), + hex::encode(&sha1_hmac(b"", b"")[..]), "fbdb1d1b18aa6c08324b7d64b71fb76370690e1d" ); - assert_eq!(&sha1_hmac(b"The quick brown fox jumps over the lazy dog", b"key")[..].to_hex(), "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"); + assert_eq!( + hex::encode( + &sha1_hmac( + b"The quick brown fox jumps over the lazy dog", + b"key" + )[..] + ), + "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9" + ); } |