is_encrypted¶
-
EncryptHelper.
is_encrypted
(data: Union[str, bytes], key: Union[str, bytes] = None) → bool[source]¶ Returns True if the passed
data
appears to be encrypted. Can only verify encryption if the samekey
that was used to encrypt the data is passed.- Parameters
data (str) – The data to check for encryption, either as a string or bytes
key (str) – Base64 encoded Fernet symmetric key for decrypting data. If empty, fallback to
encrypt_key
- Raises
EncryptKeyMissing – Either no key was passed, or something is wrong with the key.
- Return bool is_encrypted
True if the data is encrypted, False if it’s not encrypted or wrong key used.