from_password¶
-
classmethod
EncryptHelper.from_password(password: Union[str, bytes], salt: Union[str, bytes], **settings)[source]¶ Create an instance of
EncryptHelper(or inheriting class) from a password derived Fernet key, instead of a pre-generated Fernet key.See
password_key()for more detailed usage information.Example
>>> enc = EncryptHelper.from_password('MySecurePass', salt=b'Sup3rseCr3tsalt') >>> d = enc.encrypt('hello') >>> enc.decrypt(d) 'hello'
- Parameters
password – A password to generate the key from, as
strorbytessalt – The salt to use when generating the key, as
strorbytesIfsaltis a string, it can also be passed in base64 format.