File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ byteorder = "1.0"
14
14
bytes = " 1.0"
15
15
fallible-iterator = " 0.2"
16
16
hmac = " 0.10"
17
- md5 = " 0.7 "
17
+ md-5 = " 0.9 "
18
18
memchr = " 2.0"
19
19
rand = " 0.8"
20
20
sha2 = " 0.9"
Original file line number Diff line number Diff line change 1
1
//! Authentication protocol support.
2
- use md5:: Context ;
2
+ use md5:: { Digest , Md5 } ;
3
3
4
4
pub mod sasl;
5
5
@@ -10,14 +10,13 @@ pub mod sasl;
10
10
/// `PasswordMessage` message.
11
11
#[ inline]
12
12
pub fn md5_hash ( username : & [ u8 ] , password : & [ u8 ] , salt : [ u8 ; 4 ] ) -> String {
13
- let mut context = Context :: new ( ) ;
14
- context. consume ( password) ;
15
- context. consume ( username) ;
16
- let output = context. compute ( ) ;
17
- context = Context :: new ( ) ;
18
- context. consume ( format ! ( "{:x}" , output) ) ;
19
- context. consume ( & salt) ;
20
- format ! ( "md5{:x}" , context. compute( ) )
13
+ let mut md5 = Md5 :: new ( ) ;
14
+ md5. update ( password) ;
15
+ md5. update ( username) ;
16
+ let output = md5. finalize_reset ( ) ;
17
+ md5. update ( format ! ( "{:x}" , output) ) ;
18
+ md5. update ( & salt) ;
19
+ format ! ( "md5{:x}" , md5. finalize( ) )
21
20
}
22
21
23
22
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments