Skip to content

decrypt

Core logic to decrypt encrypted data on mirrored cache files (encryption key must be already available)

Classes:

  • CacheDecryptor

    Class to decrypt the encrypted data on cache files

Functions:

  • sanitize_content

    Function to sanitize plain text fully-decrypted content from bytes values

CacheDecryptor

CacheDecryptor(keyfile: str = '')

Class to decrypt the encrypted data on cache files

C-tor

Parameters:

  • keyfile

    (str, default: '' ) –

    Encryption key file

Methods:

decompose_encrypted_data staticmethod

decompose_encrypted_data(encrypted_data: bytes) -> Dict[str, bytes]

Function to decompose the encrypted data into the 3 required segments

Parameters:

  • encrypted_data

    (bytes) –

    Encrypted data (bytes)

Returns:

  • Dict[str, bytes]

    Dict of encrypted data segments

decrypt

decrypt(target_filename: str) -> List[Dict[str, Any]] | Dict[str, Any] | None

Function to decrypt the encrypted data

Parameters:

  • target_filename

    (str) –

    Target filename

Returns:

  • Any | None

    Decrypted data

export_json staticmethod

export_json(data_: List[Dict[str, Any]] | Dict[str, Any] | None, json_filename: str) -> bool

Function

Parameters:

Returns:

  • bool

    Boolean

get_bytes_length staticmethod

get_bytes_length(d: Dict[str, bytes | bool]) -> None

Function to get/print binary data

Parameters:

Returns:

  • None

    Nothing

get_symmetric_key

get_symmetric_key(key_file: str) -> bytes | None

Function to load the symmetric key from key file

Parameters:

  • key_file

    (str) –

    Key file

Returns:

  • bytes | None

    Symmetric key, nothing otherwise

load_file staticmethod

load_file(filename: str) -> Dict[str, bytes | bool]

Function to load a cache file (encrypted binary property list)

Parameters:

  • filename

    (str) –

    Filename

Returns:

  • Dict[str, bytes | bool]

    Status + signature + encrypted data

sanitize_content

sanitize_content(c: List[Dict[str, Any]] | Dict[str, Any]) -> List[Dict[str, Any]] | Dict[str, Any]

Function to sanitize plain text fully-decrypted content from bytes values which cannot be serialized via JSON package (for on-disk persistence)

Parameters:

Returns:

  • List[Dict[str, Any]]

    Sanitized content