pub fn encode_credentials(username: &str, password: &str) -> String
Available on crate feature
basic-scheme
only.Expand description
Encodes the given credentials.
This can be used to preemptively send Basic
authentication, without
sending an unauthenticated request and waiting for a 401 Unauthorized
response.
The caller should use the returned string as an Authorization
or
Proxy-Authorization
header value.
The caller is responsible for username
and password
being in the
correct format. Servers may expect arguments to be in Unicode
Normalization Form C as noted in RFC 7617 section
2.1.
assert_eq!(
http_auth::basic::encode_credentials("Aladdin", "open sesame"),
"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
);