Модуль crypt в стандартной библиотеке Python устарел. При импорте отображается следующее предупреждение:
Код: Выделить всё
DeprecationWarning: 'crypt' is deprecated and slated for removal in Python 3.13
Вот первая попытка замены crypt.crypt один в один, но вывод отличается от того, что генерирует crypt.
Код: Выделить всё
import base64
import crypt
import secrets
from passlib.hash import sha512_crypt
secret_bytes = secrets.token_bytes(60)
secret = base64.standard_b64encode(secret_bytes).decode()
pw = sha512_crypt.using(salt='').hash(secret).split('$')[-1]
print(f'passlib: $6$${pw}')
pw = crypt.crypt(secret, salt='$6$')
print(f'crypt: {pw}')
Код: Выделить всё
passlib: $6$$hdHFHtZ76R54qDgAEh607JrTGwjhphIdb3PYVr6gxiyV1oaDXTuuX/6IfPfqUVWUEhdK3U97tgoObPrDtzeJl.
crypt: $6$$0d/bb9nahTRv6XcGU4pCx..4/rzTcfg4hIGdihTK8M1DPC4PqVzMOEgz8O9DKG14yKE4uQZQdDXC8gl3hkINM0
Подробнее здесь: https://stackoverflow.com/questions/785 ... rypt-crypt