hdx.utilities.encoding

Encoding utilities.

str_to_base64

def str_to_base64(string: str) -> str

[view_source]

Base 64 encode string.

Arguments:

  • string str - String to encode

Returns:

  • str - Base 64 encoded string

base64_to_str

def base64_to_str(bstring: str) -> str

[view_source]

Base 64 decode string.

Arguments:

  • bstring str - Base 64 encoded string to encode

Returns:

  • str - Decoded string

basicauth_encode

def basicauth_encode(username: str, password: str) -> str

[view_source]

Returns an HTTP basic authentication string given a username and password.

Inspired by: https://github.com/rdegges/python-basicauth/blob/master/basicauth.py#L16

Arguments:

  • username str - Username
  • password str - Password

Returns:

  • str - Basic authentication string

basicauth_decode

def basicauth_decode(encoded_string: str) -> Tuple[str, str]

[view_source]

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

Arguments:

  • encoded_string str - String to decode

Returns:

Tuple[str, str]: Tuple of form (username, password)