Tools.crypto

This is a module that contains all the cryptography tools.

Module Contents

Functions

encryptBasicString(→ str)

Encrypts a string with a key using the Fernet algorithm

decryptBasicString(→ str)

Decrypts a string with a key using the Fernet algorithm

generateKey(→ str)

Generates a key for the Fernet algorithm

hashString(→ str)

Hashes a string with a given mode

Tools.crypto.encryptBasicString(to_encrypt: str, key: str) str

Encrypts a string with a key using the Fernet algorithm

Parameters:
  • to_encrypt – The string to encrypt

  • key – The key to encrypt the string with

Returns:

The encrypted string

Tools.crypto.decryptBasicString(to_decrypt: str, key: str) str

Decrypts a string with a key using the Fernet algorithm

Parameters:
  • to_decrypt – The encrypted string to decrypt

  • key – The key to decrypt the string with

Returns:

The decrypted string

Tools.crypto.generateKey() str

Generates a key for the Fernet algorithm

Returns:

The generated key

Tools.crypto.hashString(to_hash: str, mode='sha256') str

Hashes a string with a given mode

Parameters:
  • to_hash – The string to hash

  • mode – The mode to hash the string with (sha256, sha512, sha224, sha384, sha1, md5)

Raises:

ValueError – If the mode is invalid

Returns:

The hashed string