glic3rinu / passlib

Automatically exported from code.google.com/p/passlib
Other
15 stars 3 forks source link

DeprecationWarning: 'crypt' is deprecated and slated for removal in Python 3.13 #58

Open jmillandev opened 6 months ago

jmillandev commented 6 months ago

I'm having a warning on my test cases because crypt is deprecated.

This is my code

from passlib.context import CryptContext
from passlib.exc import UnknownHashError

context = CryptContext(schemes=["bcrypt"], deprecated="auto")

class PasslibUnidirectionalEncryptor:
    def encrypt(self, value: str) -> str:
        return context.hash(value)

    def compare(self, value: str, encrypted_value: str) -> bool:
        try:
            return context.verify(value, encrypted_value)
        except UnknownHashError:
            return False

This is the warning error:

  /usr/local/lib/python3.11/site-packages/passlib/utils/__init__.py:854: DeprecationWarning: 'crypt' is deprecated and slated for removal in Python 3.13
    from crypt import crypt as _crypt