File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ members = [
2020[dependencies ]
2121http = " 0.2.0"
2222headers-core = { version = " 0.2" , path = " ./headers-core" }
23- base64 = " 0.13 "
23+ base64 = " 0.21.3 "
2424bytes = " 1"
2525mime = " 0.3.14"
2626sha1 = " 0.10"
Original file line number Diff line number Diff line change 11//! Authorization header and types.
22
3- use base64;
3+ use base64:: engine:: general_purpose:: STANDARD as ENGINE ;
4+ use base64:: Engine ;
45use bytes:: Bytes ;
56
67use util:: HeaderValueString ;
@@ -158,7 +159,8 @@ impl Credentials for Basic {
158159 let bytes = & value. as_bytes ( ) [ "Basic " . len ( ) ..] ;
159160 let non_space_pos = bytes. iter ( ) . position ( |b| * b != b' ' ) ?;
160161 let bytes = & bytes[ non_space_pos..] ;
161- let bytes = base64:: decode ( bytes) . ok ( ) ?;
162+
163+ let bytes = ENGINE . decode ( bytes) . ok ( ) ?;
162164
163165 let decoded = String :: from_utf8 ( bytes) . ok ( ) ?;
164166
@@ -169,7 +171,7 @@ impl Credentials for Basic {
169171
170172 fn encode ( & self ) -> HeaderValue {
171173 let mut encoded = String :: from ( "Basic " ) ;
172- base64 :: encode_config_buf ( & self . decoded , base64 :: STANDARD , & mut encoded) ;
174+ ENGINE . encode_string ( & self . decoded , & mut encoded) ;
173175
174176 let bytes = Bytes :: from ( encoded) ;
175177 HeaderValue :: from_maybe_shared ( bytes)
Original file line number Diff line number Diff line change 1- use base64;
1+ use base64:: engine:: general_purpose:: STANDARD as ENGINE ;
2+ use base64:: Engine ;
23use bytes:: Bytes ;
34use sha1:: { Digest , Sha1 } ;
45
@@ -39,7 +40,7 @@ fn sign(key: &[u8]) -> SecWebsocketAccept {
3940 let mut sha1 = Sha1 :: default ( ) ;
4041 sha1. update ( key) ;
4142 sha1. update ( & b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11" [ ..] ) ;
42- let b64 = Bytes :: from ( base64 :: encode ( & sha1. finalize ( ) ) ) ;
43+ let b64 = Bytes :: from ( ENGINE . encode ( & sha1. finalize ( ) ) ) ;
4344
4445 let val = :: HeaderValue :: from_maybe_shared ( b64) . expect ( "base64 is a valid value" ) ;
4546
You can’t perform that action at this time.
0 commit comments