Server.subroutes.crypto

Module Contents

Functions

encrypt(→ Dict[str, str])

Encrypts a string with a key.

decrypt(→ Union[dict, str])

Decrypts a string with a key.

generate_key(→ str)

Generates a key.

hash_string(→ str)

Hashes a string.

Attributes

router

Server.subroutes.crypto.router
Server.subroutes.crypto.encrypt(text: str, key: str | None = None) Dict[str, str]

Encrypts a string with a key.

Parameters:
  • text – The string to encrypt

  • key – [Optional] The key to encrypt with. If not provided, a new key will be generated.

Returns:

A dictionary with the encrypted string and the key

Server.subroutes.crypto.decrypt(text: str, key: str) dict | str

Decrypts a string with a key.

Parameters:
  • text – The string to decrypt

  • key – The key to decrypt with

Returns:

A dictionary with the decrypted string

Server.subroutes.crypto.generate_key() str

Generates a key.

Returns:

A dictionary with the generated key

Server.subroutes.crypto.hash_string(text: str, mode: str | None = 'sha256') str

Hashes a string.

Parameters:
  • text – The string to hash

  • mode – [Optional] The mode to hash with. Default is sha256

Returns:

A dictionary with the hashed string