diff --git a/python/online/fxreader/pr34/commands_typed/crypto.py b/python/online/fxreader/pr34/commands_typed/crypto.py index fb20856..ab3a8b6 100644 --- a/python/online/fxreader/pr34/commands_typed/crypto.py +++ b/python/online/fxreader/pr34/commands_typed/crypto.py @@ -1,7 +1,7 @@ import base64 import os -from typing import (Literal, overload,) +from typing import (Literal, overload, Optional,) class PasswordUtils: @overload @@ -25,10 +25,12 @@ class PasswordUtils: cls, secret: str, mode: Literal['bytes', 'base64'], + salt: Optional[bytes] = None, ) -> tuple[str, str] | tuple[bytes, bytes]: from cryptography.hazmat.primitives.kdf.scrypt import Scrypt - salt = os.urandom(16) + if salt is None: + salt = os.urandom(16) # derive kdf = Scrypt( diff --git a/python/online/fxreader/pr34/tests/test_crypto.py b/python/online/fxreader/pr34/tests/test_crypto.py index f4da055..60e7881 100644 --- a/python/online/fxreader/pr34/tests/test_crypto.py +++ b/python/online/fxreader/pr34/tests/test_crypto.py @@ -3,7 +3,7 @@ import unittest class TestCrypto(unittest.TestCase): - def test_password_utils(self): + def test_password_utils(self) -> None: salt = b'asdfasdfasdf' self.assertEqual(