summaryrefslogtreecommitdiffstats
path: root/src/sha1.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-04-09 03:04:54 -0400
committerJesse Luehrs <doy@tozt.net>2019-04-09 03:20:43 -0400
commit4c12a9eed43b6c0a2c3b194a7201ba25e0b8432b (patch)
tree8c8c5c1f92b955e05171b66b3a8d125608feaabf /src/sha1.rs
parentf92b84f214923a180b455eb7f5dbb69f6973db87 (diff)
downloadmatasano-4c12a9eed43b6c0a2c3b194a7201ba25e0b8432b.tar.gz
matasano-4c12a9eed43b6c0a2c3b194a7201ba25e0b8432b.zip
stop using rustc_serialize
Diffstat (limited to 'src/sha1.rs')
-rw-r--r--src/sha1.rs17
1 files changed, 11 insertions, 6 deletions
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"
+ );
}