[+] improve crypto
This commit is contained in:
parent
731c507b95
commit
add9d858d8
@ -1,7 +1,7 @@
|
||||
import base64
|
||||
import os
|
||||
|
||||
from typing import (Literal, overload,)
|
||||
from typing import (Literal, overload, Optional,)
|
||||
|
||||
class PasswordUtils:
|
||||
@overload
|
||||
@ -25,9 +25,11 @@ 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
|
||||
|
||||
if salt is None:
|
||||
salt = os.urandom(16)
|
||||
|
||||
# derive
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user