hdx.utilities.encoding
module hdx.utilities.encoding
Encoding utilities.
Functions
-
str_to_base64 — Base 64 encode string.
-
base64_to_str — Base 64 decode string.
-
basicauth_encode — Returns an HTTP basic authentication string given a username and password.
-
basicauth_decode — Decode a HTTP basic authentication string. Returns a tuple of the form (username, password), and raises ValueError if decoding fails.
str_to_base64(string: str) → str
Base 64 encode string.
Parameters
-
string : str — String to encode
Returns
-
str — Base 64 encoded string
base64_to_str(bstring: str) → str
Base 64 decode string.
Parameters
-
bstring : str — Base 64 encoded string to encode
Returns
-
str — Decoded string
basicauth_encode(username: str, password: str) → str
Returns an HTTP basic authentication string given a username and password.
Inspired by: https://github.com/rdegges/python-basicauth/blob/master/basicauth.py#L16
Parameters
-
username : str — Username
-
password : str — Password
Returns
-
str — Basic authentication string
Raises
-
ValueError
basicauth_decode(encoded_string: str) → tuple[str, str]
Decode a HTTP basic authentication string. Returns a tuple of the form (username, password), and raises ValueError if decoding fails.
Inspired by: https://github.com/rdegges/python-basicauth/blob/master/basicauth.py#L27
Parameters
-
encoded_string : str — String to decode
Returns
-
tuple[str, str] — Tuple of form (username, password)
Raises
-
ValueError