Function
_get_fernet
(salt: bytes, password: str)
Source from the content-addressed store, hash-verified
| 77 | |
| 78 | |
| 79 | def _get_fernet(salt: bytes, password: str) -> Fernet: |
| 80 | # https://cryptography.io/en/latest/hazmat/primitives/key-derivation-functions/#argon2id |
| 81 | kdf = Argon2id( |
| 82 | salt=salt, |
| 83 | length=32, |
| 84 | iterations=1, |
| 85 | lanes=4, |
| 86 | memory_cost=64 * 1024, |
| 87 | ad=None, |
| 88 | secret=None, |
| 89 | ) |
| 90 | |
| 91 | key = base64.urlsafe_b64encode( |
| 92 | kdf.derive( |
| 93 | password.encode('utf-8'), |
| 94 | ), |
| 95 | ) |
| 96 | |
| 97 | return Fernet(key) |
| 98 | |
| 99 | |
| 100 | def encrypt(password: str, data: str) -> str: |
Tested by
no test coverage detected