Higher Order Abstractions

cryptoshred.entities.container_for(value, *, id=None, key_backend)
cryptoshred.entities.container_for(value, *, id=None, key_backend)
cryptoshred.entities.container_for(value, *, id=None, key_backend)
cryptoshred.entities.container_for(value, *, id=None, key_backend)
cryptoshred.entities.container_for(value, *, id=None, key_backend)
cryptoshred.entities.container_for(value, *, id=None, key_backend)

Given a value and some configuration will return the cryptocontainer for that value. Specific typing is implemented via singledispatch. If no specific way to encode the value is available the implementation will fallback to calling bytes on the passed object.

Parameters
  • value (T) – The value to provide a cryptocontainer for

  • id (UUID4) – The subject id used to find the key. If None a new key will be generated

  • key_backend (KeyBackend) – The key backend to use for persistence

Return type

CryptoContainer[Any]

Returns

The cryptocontainer containing the passed value

cryptoshred.entities.container_for_str(value, *, id=None, key_backend)

For strings

Return type

CryptoContainer[str]

cryptoshred.entities.container_for_bytes(value, *, id=None, key_backend)

For bytes

Return type

CryptoContainer[bytes]

cryptoshred.entities.container_for_base_model(value, *, id=None, key_backend)

For objects extending pydantics BaseModel

Return type

CryptoContainer[BaseModel]

cryptoshred.entities.container_for_dict(value, *, id=None, key_backend)

For good old dictionaries

Return type

CryptoContainer[dict]

cryptoshred.entities.container_for_int(value, *, id=None, key_backend)

For integers

Return type

CryptoContainer[int]

cryptoshred.convenience.find_and_decrypt_in_dict(input, key_backend)

Used internally to parse through a valid json data structure and find crypto containers which will than be decrypted. This function still needs a lot of tuning for it to be as efficient as possible. Currently it works well on smallish datasets, but if you bring long lists, also bring time.

Parameters
  • input (Union[List[Any], Dict[str, Any]]) – The json object do inspect

  • key_backend (KeyBackend) – The key backend

Return type

Any