(password: str, data: str)
| 98 | |
| 99 | |
| 100 | def encrypt(password: str, data: str) -> str: |
| 101 | salt = os.urandom(16) |
| 102 | f = _get_fernet(salt, password) |
| 103 | token = f.encrypt(data.encode('utf-8')) |
| 104 | |
| 105 | encoded_token = base64.urlsafe_b64encode(token).decode('utf-8') |
| 106 | encoded_salt = base64.urlsafe_b64encode(salt).decode('utf-8') |
| 107 | |
| 108 | return f'$argon2id${encoded_salt}${encoded_token}' |
| 109 | |
| 110 | |
| 111 | def decrypt(data: str, password: str) -> str: |
no test coverage detected