o
    5ht7                     @   sx   d Z ddlZeeZddlZddlmZ dgZdd Z	ddl
mZmZmZ e	eG dd deZG d	d
 d
eZdS )z1passlib.ifc - abstract interfaces used by Passlib    N)deprecated_methodPasswordHashc                    s    fdd}|S )z5class decorator that re-creates class using metaclassc                    s&    t | u r| S  | j| j| j S N)type__name__	__bases____dict__copy)clsmeta _/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/passlib/ifc.pybuilder   s   z(recreate_with_metaclass.<locals>.builderr   )r   r   r   r   r   recreate_with_metaclass   s   r   )ABCMetaabstractmethodabstractpropertyc                   @   s   e Zd ZdZdZdZdZdZee	dd Z
eddd	d
edd Zee	dd Zee	dddZedddZee	dd Zedddedd Zedddedd ZdZdS )r   zThis class describes an abstract interface which all password hashes
    in Passlib adhere to. Under Python 2.6 and up, this is an actual
    Abstract Base Class built using the :mod:`!abc` module.

    See the Passlib docs for full documentation.
    FNTc                 K      t d)a  
        Hash secret, returning result.
        Should handle generating salt, etc, and should return string
        containing identifier, salt & other configuration, as well as digest.

        :param \\*\\*settings_kwds:

            Pass in settings to customize configuration of resulting hash.

            .. deprecated:: 1.7

                Starting with Passlib 1.7, callers should no longer pass settings keywords
                (e.g. ``rounds`` or ``salt`` directly to :meth:`!hash`); should use
                ``.using(**settings).hash(secret)`` construction instead.

                Support will be removed in Passlib 2.0.

        :param \\*\\*context_kwds:

            Specific algorithms may require context-specific information (such as the user login).
        must be implemented by subclassNotImplementedError)r
   secretsetting_and_context_kwdsr   r   r   hashr   s   zPasswordHash.hashz1.7z2.0z.hash())
deprecatedremovedreplacementc                 O   s   | j |i |S )a  
        Legacy alias for :meth:`hash`.

        .. deprecated:: 1.7
            This method was renamed to :meth:`!hash` in version 1.7.
            This alias will be removed in version 2.0, and should only
            be used for compatibility with Passlib 1.3 - 1.6.
        r   )r
   argskwdsr   r   r   encrypt   s   zPasswordHash.encryptc                 K   r   )z.verify secret against hash, returns True/Falser   r   )r
   r   r   context_kwdsr   r   r   verify      zPasswordHash.verifyc                 K   r   )a  
        Return another hasher object (typically a subclass of the current one),
        which integrates the configuration options specified by ``kwds``.
        This should *always* return a new object, even if no configuration options are changed.

        .. todo::

            document which options are accepted.

        :returns:
            typically returns a subclass for most hasher implementations.

        .. todo::

            add this method to main documentation.
        r   r   )r
   relaxedr    r   r   r   using   s   zPasswordHash.usingc                 C   s   dS )a  
        check if hash's configuration is outside desired bounds,
        or contains some other internal option which requires
        updating the password hash.

        :param hash:
            hash string to examine

        :param secret:
            optional secret known to have verified against the provided hash.
            (this is used by some hashes to detect legacy algorithm mistakes).

        :return:
            whether secret needs re-hashing.

        .. versionadded:: 1.7
        Fr   )r
   r   r   r   r   r   needs_update   s   zPasswordHash.needs_updatec                 C   r   )z8check if hash belongs to this scheme, returns True/Falser   r   r
   r   r   r   r   identify   r$   zPasswordHash.identify)r   r   c                 K   s$   | j rtd| jdi |dS )a  
        compile settings into a configuration string for genhash()

        .. deprecated:: 1.7

            As of 1.7, this method is deprecated, and slated for complete removal in Passlib 2.0.

            For all known real-world uses, hashing a constant string
            should provide equivalent functionality.

            This deprecation may be reversed if a use-case presents itself in the mean time.
        r    Nr   )r"   r   r&   r   )r
   setting_kwdsr   r   r   	genconfig   s   zPasswordHash.genconfigc                 K   r   )a1  
        generated hash for secret, using settings from config/hash string

        .. deprecated:: 1.7

            As of 1.7, this method is deprecated, and slated for complete removal in Passlib 2.0.

            This deprecation may be reversed if a use-case presents itself in the mean time.
        r   r   )r
   r   configcontextr   r   r   genhash   s   zPasswordHash.genhash)Fr   )r   
__module____qualname____doc__is_disabledtruncate_sizetruncate_errortruncate_verify_rejectclassmethodr   r   r   r!   r#   r&   r'   r)   r,   r/   r   r   r   r   r   r   %   s<    	

 c                   @   s.   e Zd ZdZdZedddZedd ZdS )	DisabledHashzR
    extended disabled-hash methods; only need be present if .disabled = True
    TNc                 C   s
   |  dS )z
        return string representing a 'disabled' hash;
        optionally including previously enabled hash
        (this is up to the individual scheme).
        r*   r   r(   r   r   r   disableK  s   
zDisabledHash.disablec                 C   r   )z
        given a disabled-hash string,
        extract previously-enabled hash if one is present,
        otherwise raises ValueError
        zcannot restore original hash)
ValueErrorr(   r   r   r   enableU  s   zDisabledHash.enabler   )r   r0   r1   r2   r3   r7   r9   r;   r   r   r   r   r8   D  s    	r8   )r2   logging	getLoggerr   logsyspasslib.utils.decorr   __all__r   abcr   r   r   objectr   r8   r   r   r   r   <module>   s       