
     h                       d Z ddlmZ ddlZddlZ ej
                  e      ZddlZddl	Z	ddl
mZ ddlmZ ddlmZmZmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZ dd	lm Z  dd
l!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z.m/Z/ g dZ0 e1       Z2d Z3 e4dg      Z5 e6e7e7e7e3e7      Z8d Z9e:dd       Z; e4ddg      Z<dZ= G d de1      Z> G d de1      Z? G d de1      Z@ G d de@      ZAy)z-passlib.context - CryptContext implementation    )with_statementN)warn)exc)ExpectedStringErrorExpectedTypeErrorPasslibConfigWarning)get_crypt_handler_validate_handler_name)handlersto_bytes
to_unicode
splitcommaas_booltimerrng
getrandstr)BASE64_CHARS)	iteritems	num_typesirangePY2PY3unicodeSafeConfigParserNativeStringIOBytesIOunicode_or_bytes_typesnative_string_types)deprecated_methodmemoized_property)CryptContextLazyCryptContextCryptPolicyc                     | j                  d      rt        | j                  d            dz  S 	 t        |       S # t        $ r t        |       cY S w xY w)z>parse vary_rounds string to percent as [0,1) float, or integer%{Gz?)endswithfloatrstripint
ValueErrorvalues    Q/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/passlib/context.py_coerce_vary_roundsr/   *   sO    ~~cU\\#&'++5z U|s   
; AAsalt)
min_rounds
max_roundsdefault_roundsvary_rounds	salt_sizec                 2    t        | j                  d      | u S )z3detect if handler is registered or a custom handlerN)r	   namehandlers    r.   _is_handler_registeredr:   C   s    W\\40G;;    c                      y)z
    dummy function patched into handler.needs_update() by _CryptConfig
    when hash alg has been deprecated for context.
    T )hashsecrets     r.   _always_needs_updater@   G   s     r;   truncate_errorr4   zaThe CryptPolicy class has been deprecated as of Passlib 1.6, and will be removed in Passlib 1.8. c                       e Zd ZdZedd       Zedd       Zedd       Zedd       Zd Z	dZ
dZd	 Zd
 Zd ZddZddZddZddZddZddZddZddZddZy)r#   a  
    .. deprecated:: 1.6
        This class has been deprecated, and will be removed in Passlib 1.8.
        All of its functionality has been rolled into :class:`CryptContext`.

    This class previously stored the configuration options for the
    CryptContext class. In the interest of interface simplification,
    all of this class' functionality has been rolled into the CryptContext
    class itself.
    The documentation for this class is now focused on  documenting how to
    migrate to the new api. Additionally, where possible, the deprecation
    warnings issued by the CryptPolicy methods will list the replacement call
    that should be used.

    Constructors
    ============
    CryptPolicy objects can be constructed directly using any of
    the keywords accepted by :class:`CryptContext`. Direct uses of the
    :class:`!CryptPolicy` constructor should either pass the keywords
    directly into the CryptContext constructor, or to :meth:`CryptContext.update`
    if the policy object was being used to update an existing context object.

    In addition to passing in keywords directly,
    CryptPolicy objects can be constructed by the following methods:

    .. automethod:: from_path
    .. automethod:: from_string
    .. automethod:: from_source
    .. automethod:: from_sources
    .. automethod:: replace

    Introspection
    =============
    All of the informational methods provided by this class have been deprecated
    by identical or similar methods in the :class:`CryptContext` class:

    .. automethod:: has_schemes
    .. automethod:: schemes
    .. automethod:: iter_handlers
    .. automethod:: get_handler
    .. automethod:: get_options
    .. automethod:: handler_is_deprecated
    .. automethod:: get_min_verify_time

    Exporting
    =========
    .. automethod:: iter_config
    .. automethod:: to_dict
    .. automethod:: to_file
    .. automethod:: to_string

    .. note::
        CryptPolicy are immutable.
        Use the :meth:`replace` method to mutate existing instances.

    .. deprecated:: 1.6
    c                 p    t        t        dz   t        d        | t        j	                  |||            S )aW  create a CryptPolicy instance from a local file.

        .. deprecated:: 1.6

        Creating a new CryptContext from a file, which was previously done via
        ``CryptContext(policy=CryptPolicy.from_path(path))``, can now be
        done via ``CryptContext.from_path(path)``.
        See :meth:`CryptContext.from_path` for details.

        Updating an existing CryptContext from a file, which was previously done
        ``context.policy = CryptPolicy.from_path(path)``, can now be
        done via ``context.load_path(path)``.
        See :meth:`CryptContext.load_path` for details.
        zInstead of ``CryptPolicy.from_path(path)``, use ``CryptContext.from_path(path)``  or ``context.load_path(path)`` for an existing CryptContext.   
stacklevel_internal_context)r   	_preambleDeprecationWarningr!   	from_path)clspathsectionencodings       r.   rK   zCryptPolicy.from_path   sG      	YMM  A		/
 \%;%;D'<D&F G 	Gr;   c                 p    t        t        dz   t        d        | t        j	                  |||            S )aU  create a CryptPolicy instance from a string.

        .. deprecated:: 1.6

        Creating a new CryptContext from a string, which was previously done via
        ``CryptContext(policy=CryptPolicy.from_string(data))``, can now be
        done via ``CryptContext.from_string(data)``.
        See :meth:`CryptContext.from_string` for details.

        Updating an existing CryptContext from a string, which was previously done
        ``context.policy = CryptPolicy.from_string(data)``, can now be
        done via ``context.load(data)``.
        See :meth:`CryptContext.load` for details.
        zInstead of ``CryptPolicy.from_string(source)``, use ``CryptContext.from_string(source)`` or ``context.load(source)`` for an existing CryptContext.rD   rE   rG   )r   rI   rJ   r!   from_string)rL   sourcerN   rO   s       r.   rQ   zCryptPolicy.from_string   sG      	YFF  A		/
 \%=%=fg>F&H I 	Ir;   c                    |rt        t        dz   t        d       t        t              rS t        t
              r | t        d	i       S t        t        t        f      st        dt                    t        fddD              sj                  d      s | t        j                              S  | t        j                              S )
a  create a CryptPolicy instance from some source.

        this method autodetects the source type, and invokes
        the appropriate constructor automatically. it attempts
        to detect whether the source is a configuration string, a filepath,
        a dictionary, or an existing CryptPolicy instance.

        .. deprecated:: 1.6

        Create a new CryptContext, which could previously be done via
        ``CryptContext(policy=CryptPolicy.from_source(source))``, should
        now be done using an explicit method: the :class:`CryptContext`
        constructor itself, :meth:`CryptContext.from_path`,
        or :meth:`CryptContext.from_string`.

        Updating an existing CryptContext, which could previously be done via
        ``context.policy = CryptPolicy.from_source(source)``, should
        now be done using an explicit method: :meth:`CryptContext.update`,
        or :meth:`CryptContext.load`.
        zInstead of ``CryptPolicy.from_source()``, use ``CryptContext.from_string(path)``  or ``CryptContext.from_path(source)``, as appropriate.rD   rE   rG   z?source must be CryptPolicy, dict, config string, or file path: c              3   &   K   | ]  }|v  
 y wNr=   ).0crR   s     r.   	<genexpr>z*CryptPolicy.from_source.<locals>.<genexpr>   s     /f/s   z
	z 	./;:r=   )r   rI   rJ   
isinstancer#   dictr!   bytesr   	TypeErrortypeanystriprQ   rK   )rL   rR   _warns    ` r.   from_sourcezCryptPolicy.from_source   s    , KK $	3
 fk*M%)?)?@@FU7O426v,A B B/h//v||I7N)A)A&)IJJ)?)?)GHHr;   c                 `   |rt        t        dz   t        d       t        |      dk(  rt	        d      t        |      dk(  r| j                  |d   d      S i }|D ]>  }|j                  | j                  |d      j                  j                  d	
             @  | t        di |      S )a  create a CryptPolicy instance by merging multiple sources.

        each source is interpreted as by :meth:`from_source`,
        and the results are merged together.

        .. deprecated:: 1.6
            Instead of using this method to merge multiple policies together,
            a :class:`CryptContext` instance should be created, and then
            the multiple sources merged together via :meth:`CryptContext.load`.
        zwInstead of ``CryptPolicy.from_sources()``, use the various CryptContext constructors  followed by ``context.update()``.rD   rE   r   zno sources specified   Fr`   TresolverG   r=   )
r   rI   rJ   lenr+   ra   update_contextto_dictr!   )rL   sourcesr`   kwdsrR   s        r.   from_sourceszCryptPolicy.from_sources   s     66 $	3
 w<1344w<1??71:U?;; 	]FKKe<EEMMVZM[\	]\%9D%9::r;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       | g}|r|j	                  |       |r|j                  |       t        j                  |d      S )zcreate a new CryptPolicy, optionally updating parts of the
        existing configuration.

        .. deprecated:: 1.6
            Callers of this method should :meth:`CryptContext.update` or
            :meth:`CryptContext.copy` instead.
        zXInstead of ``context.policy.replace()``, use ``context.update()`` or ``context.copy()``.rD   rE   zzInstead of ``CryptPolicy().replace()``, create a CryptContext instance and use ``context.update()`` or ``context.copy()``.Frd   )_stub_policyr   rI   rJ   extendappendr#   rm   )selfargsrl   rk   s       r.   replacezCryptPolicy.replace  s     CC $3
 CC $	3
 (NN4 NN4 ''u'==r;   NFc                 \   |j                  dd       }|rBt        |t              sJ || _        |j                  dd      | _        |s|rJ d|d|       y |r+t        |      dk7  rt        d      |rt        d      |d	   }t        t        d
z   t        d       t        di || _        y )NrH   ro   Fzunexpected args:  rc   z%only one positional argument acceptedz&cannot specify positional arg and kwdsr   zInstead of constructing a CryptPolicy instance, create a CryptContext directly, or use ``context.update()`` and ``context.load()`` to reconfigure existing CryptContext instances.rD   rE   r=   )
poprY   r!   ri   ro   rg   r\   r   rI   rJ   )rr   rs   rl   contexts       r.   __init__zCryptPolicy.__init__1  s    ((.5g|44#DM $ ?DM4'MMt9>#$KLL#$LMMAw
 $3 )040DMr;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       t	        | j
                  j                               S )zreturn True if policy defines *any* schemes for use.

        .. deprecated:: 1.6
            applications should use ``bool(context.schemes())`` instead.
            see :meth:`CryptContext.schemes`.
        zMInstead of ``context.policy.has_schemes()``, use ``bool(context.schemes())``.rD   rE   zoInstead of ``CryptPolicy().has_schemes()``, create a CryptContext instance and use ``bool(context.schemes())``.)ro   r   rI   rJ   boolri   schemesrr   s    r.   has_schemeszCryptPolicy.has_schemesJ  s_     44 $3
 44 $	3
 DMM))+,,r;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       | j                  j                  dd      S )zreturn iterator over handlers defined in policy.

        .. deprecated:: 1.6
            applications should use ``context.schemes(resolve=True))`` instead.
            see :meth:`CryptContext.schemes`.
        zUInstead of ``context.policy.iter_handlers()``, use ``context.schemes(resolve=True)``.rD   rE   zwInstead of ``CryptPolicy().iter_handlers()``, create a CryptContext instance and use ``context.schemes(resolve=True)``.Trf   unconfigured)ro   r   rI   rJ   ri   r|   r}   s    r.   iter_handlerszCryptPolicy.iter_handlers^  sa     :: $3
 :: $	3
 }}$$T$EEr;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       t	        | j
                  j                  |d            S )zreturn list of schemes defined in policy.

        .. deprecated:: 1.6
            applications should use :meth:`CryptContext.schemes` instead.
        zCInstead of ``context.policy.schemes()``, use ``context.schemes()``.rD   rE   zeInstead of ``CryptPolicy().schemes()``, create a CryptContext instance and use ``context.schemes()``.Tr   )ro   r   rI   rJ   listri   r|   rr   rf   s     r.   r|   zCryptPolicy.schemesr  sf     .. $3
 .. $	3
 DMM))')MNNr;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       	 | j                  j                  ||d      S # t        $ r |r Y yw xY w)a8  return handler as specified by name, or default handler.

        .. deprecated:: 1.6
            applications should use :meth:`CryptContext.handler` instead,
            though note that the ``required`` keyword has been removed,
            and the new method will always act as if ``required=True``.
        zGInstead of ``context.policy.get_handler()``, use ``context.handler()``.rD   rE   ziInstead of ``CryptPolicy().get_handler()``, create a CryptContext instance and use ``context.handler()``.Tr   N)ro   r   rI   rJ   ri   r9   KeyError)rr   r7   categoryrequireds       r.   get_handlerzCryptPolicy.get_handler  s~     .. $3
 .. $	3	==((xd(KK 			s   A A.-A.c                 (    t        dt        d       y)ar  get min_verify_time setting for policy.

        .. deprecated:: 1.6
            min_verify_time option will be removed entirely in passlib 1.8

        .. versionchanged:: 1.7
            this method now always returns the value automatically
            calculated by :meth:`CryptContext.min_verify_time`,
            any value specified by policy is ignored.
        znget_min_verify_time() and min_verify_time option is deprecated and ignored, and will be removed in Passlib 1.8rD   rE   r   )r   rJ   )rr   r   s     r.   get_min_verify_timezCryptPolicy.get_min_verify_time  s     	 23E	 r;   c                    | j                   rt        t        dz   t        d       nt        t        dz   t        d       t	        |d      r|j
                  }| j                  j                  j                  ||      d   S )aL  return dictionary of options specific to a given handler.

        .. deprecated:: 1.6
            this method has no direct replacement in the 1.6 api, as there
            is not a clearly defined use-case. however, examining the output of
            :meth:`CryptContext.to_dict` should serve as the closest alternative.
        z=``context.policy.get_options()`` will no longer be available.rD   rE   z<``CryptPolicy().get_options()`` will no longer be available.r7   r   )	ro   r   rI   rJ   hasattrr7   ri   _config_get_record_options_with_flagrr   r7   r   s      r.   get_optionszCryptPolicy.get_options  sw     PQ#3 OP#3 4 99D}}$$BB4RSTUUr;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       t	        |d      r|j
                  }| j                  j                  ||      j                  S )aB  check if handler has been deprecated by policy.

        .. deprecated:: 1.6
            this method has no direct replacement in the 1.6 api, as there
            is not a clearly defined use-case. however, examining the output of
            :meth:`CryptContext.to_dict` should serve as the closest alternative.
        zG``context.policy.handler_is_deprecated()`` will no longer be available.rD   rE   zF``CryptPolicy().handler_is_deprecated()`` will no longer be available.r7   )	ro   r   rI   rJ   r   r7   ri   r9   
deprecatedr   s      r.   handler_is_deprecatedz!CryptPolicy.handler_is_deprecated  sq     Z[#3 YZ#3 4 99D}}$$T84???r;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       | j                  |rfdd d}nj
                  d fd	j                  j                  |      D        S )
ziterate over key/value pairs representing the policy object.

        .. deprecated:: 1.6
            applications should use :meth:`CryptContext.to_dict` instead.
        zOInstead of ``context.policy.iter_config()``, use ``context.to_dict().items()``.rD   rE   zqInstead of ``CryptPolicy().iter_config()``, create a CryptContext instance and use ``context.to_dict().items()``.c                 F    j                  |       j                  dd      S )N__.)_render_config_keyrt   )keyrx   s    r.   
render_keyz+CryptPolicy.iter_config.<locals>.render_key  s!    11#6>>tSIIr;   c                 T    t        | t        t        f      rdj                  |       } | S )N, )rY   r   tuplejoinr,   s    r.   render_valuez-CryptPolicy.iter_config.<locals>.render_value  s#    ed5\2 IIe,Er;   Fc                     | S rU   r=   r,   s    r.   <lambda>z)CryptPolicy.iter_config.<locals>.<lambda>  s     r;   c              3   D   K   | ]  \  }} |       |      f  y wrU   r=   )rV   r   r-   r   r   s      r.   rX   z*CryptPolicy.iter_config.<locals>.<genexpr>  s+      
U _l512
s    )ro   r   rI   rJ   ri   r   r   iter_config)rr   inirf   rx   r   r   s      @@@r.   r   zCryptPolicy.iter_config  s     66 $3
 66 $	3 --J G 33J.L
%oo99'B
 	
r;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       | j                  j                  |      S )zexport policy object as dictionary of options.

        .. deprecated:: 1.6
            applications should use :meth:`CryptContext.to_dict` instead.
        zCInstead of ``context.policy.to_dict()``, use ``context.to_dict()``.rD   rE   zeInstead of ``CryptPolicy().to_dict()``, create a CryptContext instance and use ``context.to_dict()``.)ro   r   rI   rJ   ri   rj   r   s     r.   rj   zCryptPolicy.to_dict  s\     .. $3
 .. $	3
 }}$$W--r;   c                 
   | j                   rt        t        dz   t        d       nt        t        dz   t        d       | j                  j                  |      }t        r|j                  d      }|j                  |       y)zexport policy to file.

        .. deprecated:: 1.6
            applications should use :meth:`CryptContext.to_string` instead,
            and then write the output to a file as desired.
        zYInstead of ``context.policy.to_file(stream)``, use ``stream.write(context.to_string())``.rD   rE   z{Instead of ``CryptPolicy().to_file(stream)``, create a CryptContext instance and use ``stream.write(context.to_string())``.rN   utf-8N)	ro   r   rI   rJ   ri   	to_stringr   encodewrite)rr   streamrN   outs       r.   to_filezCryptPolicy.to_file  s{     >> $3
 >> $	3
 mm%%g%6**W%CSr;   c                     | j                   rt        t        dz   t        d       nt        t        dz   t        d       | j                  j                  |      }|r|j                  |      }|S )zexport policy to file.

        .. deprecated:: 1.6
            applications should use :meth:`CryptContext.to_string` instead.
        zGInstead of ``context.policy.to_string()``, use ``context.to_string()``.rD   rE   ziInstead of ``CryptPolicy().to_string()``, create a CryptContext instance and use ``context.to_string()``.r   )ro   r   rI   rJ   ri   r   r   )rr   rN   rO   r   s       r.   r   zCryptPolicy.to_string.  st     00 $3
 00 $	3
 mm%%g%6**X&C
r;   passlibr   TFNNFrU   )FFr   )r   N)__name__
__module____qualname____doc__classmethodrK   rQ   ra   rm   rt   ri   ro   ry   r~   r   r|   r   r   r   r   r   rj   r   r   r=   r;   r.   r#   r#   X   s    8x G G. I I. %I %IN ; ;4>@ H L
12-(F(O&: V*@2"
H.&.r;   r#   c                       e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZd Zd Zd Zd Zd Zi fdZd	 Zi fd
Zd Zed        Zd Zd Zd Zd Zd Zedd       Zd Zd ZddZ ddZ!e"d        Z#ddZ$y)_CryptConfiga  parses, validates, and stores CryptContext config

    this is a helper used internally by CryptContext to handle
    parsing, validation, and serialization of its config options.
    split out from the main class, but not made public since
    that just complicates interface too much (c.f. CryptPolicy)

    :arg source: config as dict mapping ``(cat,scheme,option) -> value``
    Nc                     | j                  |j                  d             | j                  |       | j                          | j	                          y )NNNr|   )_init_scheme_listget_init_options_init_default_schemes_init_records)rr   rR   s     r.   ry   z_CryptConfig.__init__z  s@    vzz*?@A6"""$r;   c                    g }g }t        |t              rt        |      }|xs dD ]  }t        |d      r|}|j                  }t        |       n?t        |t              rt        |      }|j                  }nt        dt        |      z        ||v rt        d|      |j                  |       |j                  |        t        |      | _        t        |      | _        y)z,initialize .handlers and .schemes attributesr=   r7   z+scheme must be name or CryptHandler, not %rz"multiple handlers with same name: N)rY   r   r   r   r7   r
   r	   r\   r]   r   rq   r   r   r|   )rr   datar   r|   elemr9   schemes          r.   r   z_CryptConfig._init_scheme_list  s    d/0d#DJB 	#DtV$ &v.D"56+D1  !)+/:!6 7 7   & ) * * OOG$NN6")	#, hW~r;   c                    | j                   }| j                  }i x| _        }i x| _        }t	               }t        |      D ]  \  \  }}}	}
|j                  |       |}|s|s
|	t        v rd}|rT ||	|
      \  }	}
|dk(  r|	t        vrt        d|	dt               |dk(  rt        dt               	 ||   }	 ||   }|
||	<   |r|	dk(  rt        d       |||	|
      \  }	}
|	dk(  r	 ||	   }|
||<    |j                  d       t        t        |            | _        y# t        $ r
 |	|
i||<   Y w xY w# t        $ r ||	|
ii||<   Y 	w xY w# t        $ r ||
i||	<   Y  w xY w)	zYload config dict into internal representation,
        and init .categories attr
        allzThe 'zv' option should be configured per-algorithm, and not set globally in the context; This will be an error in Passlib 2.0zThe 'all' scheme is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0; Please configure options on a per-algorithm basis.r|   z4'schemes' context option is not allowed per categorymin_verify_timeN)_norm_scheme_option_norm_context_option_scheme_options_context_optionssetr   add_global_settingsr   r   rJ   r   discardr   sorted
categories)rr   rR   norm_scheme_optionnorm_context_optionscheme_optionscontext_optionsr   catr   r   r-   explicit_schemecategory_map
option_maps                 r.   r   z_CryptConfig._init_options  s   
 "55"77022~244U
 *36): 7	.%S&#NN3$Ov#1A*A /U;
U U?s2B'B !57 #e+ =>PR
0#1&#9L0%1#%6
 +0
3 3)+" $2 3 30c5A
U++.#23#7L ).L%o7	.t 	4 z 231 $ 9-0%LS)9   A.1C<-@N6*A,   8,/<OC(8s6   0D46D'ED10D14E
	E
E! E!c                     |t         v rt        |d      t        |t              rt        j                  |      }|r ||      }||fS )Nz1 option not allowed in CryptContext configuration)_forbidden_scheme_optionsr   rY   r   _coerce_scheme_optionsr   )rr   r   r-   funcs       r.   r   z _CryptConfig._norm_scheme_option  sS    ++.14 5 5 e01)--c2DUEzr;   c                    | j                   }|dk(  rKt        |d      r|j                  }nt        |t              st        |dd      |r||vrt        d      ||fS |dk(  rt        |t              rt        |      }n#t        |t        t        f      st        |dd      d|v rt        |      dkD  rCt        d	      |r6|D ]1  }t        |t              st        |dd
      ||vs%t        d|       ||fS |dk(  rt        dt               ||fS |dk(  rt        dt               ||fS |dk7  rt        d|      ||fS )Ndefaultr7   strz"default scheme not found in policyr   z
str or seqautorc   z<cannot list other schemes if ``deprecated=['auto']`` is usedzdeprecated elementz'deprecated scheme not found in policy: r   z^'min_verify_time' was deprecated in Passlib 1.6, is ignored in 1.7, and will be removed in 1.8harden_verifyzX'harden_verify' is deprecated & ignored as of Passlib 1.7.1,  and will be removed in 1.8r|   zunknown CryptContext keyword: )r|   r   r7   rY   r   r   r   r   r   r   rg   r+   r   rJ   )rr   r   r   r-   r|   r   s         r.   r   z!_CryptConfig._norm_context_option  s   ,,)uf%

':;'ui@@5/CDD< Ez; L %!45"5)U|4'|\JJ u:>$ &G H H# @F%f.AB/u>RSSW,&6<(? @ @	@  Ez %% >#% Ez O# /#%
 Ez IFGGEzr;   c                 :    | j                   j                  ||      S )zreturn dict mapping category->value for specific context option.

        .. warning:: treat return value as readonly!
        )r   r   )rr   r   _defaults      r.   get_context_optionmapz"_CryptConfig.get_context_optionmap&  s    
 $$((h77r;   c                     	 | j                   |   }|j                  d      }|r	 ||   }|||k7  r|dfS |dfS |dfS # t        $ r Y yw xY w# t        $ r Y |dfS w xY w)zreturn value of specific option, handling category inheritance.
        also returns flag indicating whether value is category-specific.
        NFNTF)r   r   r   )rr   r   r   r   r-   alts         r.   get_context_option_with_flagz)_CryptConfig.get_context_option_with_flag-  s    	005L   &%"8, =C5L9$e|ue|  		   e|s    = A 	A	A		AAc                 J    	 | j                   |   |   S # t        $ r |cY S w xY w)zsreturn all options for (scheme,category) combination

        .. warning:: treat return value as readonly!
        )r   r   )rr   r   r   r   s       r.   _get_scheme_optionmapz"_CryptConfig._get_scheme_optionmapC  s1    
	''/99 	N	s    ""c                 R    | j                   | j                  j                  |         S rU   )r   r|   index)rr   r   s     r.   get_base_handlerz_CryptConfig.get_base_handlerM  s     }}T\\//788r;   c                 t    | j                   }d| j                   v r|t        j                  j                  z  }|S )Nrounds)setting_kwdsuh	HasRoundsusing_rounds_kwds)r9   r   s     r.   expand_settingsz_CryptConfig.expand_settingsP  s5    ++w+++BLL:::Lr;   c                 D   | j                   } |dd      j                         }d}|r(|j                         }|j                   |d|             | j                  | j	                  |            }t        |      j                  |      D ]  }|j                  |        |r0t              j                  |      D ]  }|j                  |         ||d      }	|j                  |	       |r0j                  |	       |j                   |||             ||k7  rd}||fS )zreturn composite dict of all options set for scheme.
        includes options inherited from 'all' and from default category.
        result can be modified.
        returns (kwds, has_cat_specific_options)
        r   NFT)r   copyrh   r   r   r   
differencerw   )
rr   r   r   get_optionmaprl   has_cat_optionsdefkwdsallowed_settingsr   others
             r.   get_scheme_options_with_flagz)_CryptConfig.get_scheme_options_with_flagY  s    22UD)..0 iikGKKeX67  //0E0Ef0MNt9''(89 	CHHSM	7|../?@ !C ! fd+E NN5!KKfh78 w"&_$$r;   c                    | j                   } |d      j                         x}| _         |d      }| j                  }|sy|j	                  d      xs d}|j	                  d      }|s|D ]  }||vs||d<    n t        d      ||v rt        d      | j                  D ]Z  }|j	                  ||      }	|j	                  ||      }
|
s |D ]  }||	vs|||<    : t        d|z        |
|	v sNt        d|z         y)	zinitialize maps containing default scheme for each category.

        have to do this after _init_options(), since the default scheme
        is affected by the list of deprecated schemes.
        r   r   Nr=   z,must have at least one non-deprecated schemez#default scheme cannot be deprecatedz<must have at least one non-deprecated scheme for %r categoryz3default scheme for %r category cannot be deprecated)r   r   _default_schemesr|   r   r+   r   )rr   r   default_mapdep_mapr|   depsr   r   r   cdepscdefaults              r.   r   z"_CryptConfig._init_default_schemes  sO    22.;I.F.K.K.MMd+-,, {{4 &B//$'! Q%(.K%Q
 !!OPP_BCC ?? 	?CKKT*E"sG4H% EFU*+1C(E
 % &>@C&D E EU"  "8:="> ? ?	?r;   c                 |    | j                   }	 ||   S # t        $ r Y nw xY w| j                  st        d      |d   S )z+return default scheme for specific categoryz9no hash schemes configured for this CryptContext instanceN)r  r   r|   )rr   r   defaultss      r.   default_schemez_CryptConfig.default_scheme  sR    ((	H%% 		|| 3 4 4~s    	c                       j                  d       fd} |d      xs d}|r ||      }|	||k7  r|dfS |dfS )z/is scheme deprecated under particular category?r   c                     j                  | j                  d             }|y d|v rj                  |       k7  S |v S )Nr   )r   r  )r   rR   depmapr   rr   s     r.   testz2_CryptConfig.is_deprecated_with_flag.<locals>.test  sM    ZZVZZ%56F~6!!4!4S!999''r;   NFT)r   )rr   r   r   r  r-   r   r  s   ``    @r.   is_deprecated_with_flagz$_CryptConfig.is_deprecated_with_flag  sS    ++L9	( T
#ex.C5C<Dy e|r;   c                 N   i | _         i x}| _        t               x}| _        | j                  }d| j
                  z   }| j                  D ]Z  }|j                  }|j                  |j                         |D ],  } |||      \  }}	||	s | j                  ||fi ||||f<   . \ y )NrU   )
_record_lists_recordsr   context_kwdsr   r   r   r7   rh   _create_record)
rr   recordsall_context_kwdsr   r   r9   r   r   rl   r   s
             r.   r   z_CryptConfig._init_records  s    
  "$$$-/2u44,88t.
}} 	UG\\F##G$8$89! U(3FC(@%o;/+>4+>+>w+Tt+TGFCK(U	Ur;   c                 F   	  | j                   dddi|}|| usJ d       | |_        ||_	        |S # t        $ rf}t        j                  dt	        |            }|r?|j                  d      |v r,|j                  d      }t        d| j                  d|       d }~ww xY w)	NrelaxedTz&.* unexpected keyword argument '(.*)'$rc   zkeyword not supported by z
 handler: z"expected unique variant of handlerr=   )
usingr\   rematchr   groupr   r7   _Context__orig_handlerr   )r9   r   r   settingssubclserrmr   s           r.   r  z_CryptConfig._create_record  s    	 #W]]<4<8<F W$J&JJ(/%&  	BCHMAQWWQZ8+ ggaj 'c 3 4 4	s   1 	B A!BB c                 t    | j                  ||      \  }}| j                  ||      \  }}|rd|d<   |rd}||fS )a  return composite dict of options for given scheme + category.

        this is currently a private method, though some variant
        of its output may eventually be made public.

        given a scheme & category, it returns two things:
        a set of all the keyword options to pass to :meth:`_create_record`,
        and a bool flag indicating whether any of these options
        were specific to the named category. if this flag is false,
        the options are identical to the options for the default category.

        the options dict includes all the scheme-specific settings,
        as well as optional *deprecated* keyword.
        Tr   )r  r  )rr   r   r   rl   r   r-   not_inheriteds          r.   r   z*_CryptConfig._get_record_options_with_flag  sT      !% A A&( So  $;;FHM}!%D"O_$$r;   c                    	 | j                   ||f   S # t        $ r Y nw xY w|Tt        |t              sDt        r1t        |t
              r!| j                  ||j                  d            S t        |dd      |t        |t              st        |dd      |s:| j                  |      }|sJ | j                  ||      x}| j                   d|f<   |S |r,	 | j                   }||df   x}|||f<   |S # t        $ r Y nw xY wt        d|      )z5return record for specific scheme & category (cached)Nr   zstr or Noner   r   z%crypt algorithm not found in policy: )
r  r   rY   r   r   r   
get_recordr   r   r  )rr   r   r   r   recordcaches         r.   r)  z_CryptConfig.get_record  s2   	==!122 		 
8=P(Qz(G4vxw/GHH#HmZHHj9L&M#FM8DD ))(3GN59__WFN6P PFT]]4>2M 383FFvx/0  FLMMs    	C2 2	C>=C>c                     	 | j                   |   S # t        $ r Y nw xY w| j                  D cg c]  }| j                  ||       nc c}w c}x}| j                   |<   |S )zxreturn list of records for category (cached)

        this is an internal helper used only by identify_record()
        )r  r   r|   r)  )rr   r   r   r-   s       r.   _get_record_listz_CryptConfig._get_record_listD  sq    	%%h// 		
 ,,0 OOFH-0 0 	""8, s    	Ac                     t        |t              st        |d      | j                  |      D ]  }|j	                  |      s|c S  |sy| j
                  st        d      t        j                  d      )z?internal helper to identify appropriate custom handler for hashr>   Nzno crypt algorithms supportedzhash could not be identified)	rY   r   r   r-  identifyr|   r   r   UnknownHashError)rr   r>   r   r   r*  s        r.   identify_recordz_CryptConfig.identify_recordV  st     $ 67%dF33++H5 	Ft$	 :;;&&'EFFr;   c                 d    | j                  d       D ]  }|j                  s|c S  t        d      )NzLno disabled hasher present (perhaps add 'unix_disabled' to list of schemes?))r-  is_disabledRuntimeError)rr   r*  s     r.   disabled_recordz_CryptConfig.disabled_recordn  sA    ++D1 	F!!	  O P 	Pr;   c              #     K   | j                   }| j                  }t        |      }t        |      }d|v r|j                  d       |r| j                  n| j
                  }|rdt        |      f d| j                  z   D ]b  }|D ]/  }	 ||   |   }t        |t              rt        |      }|d|f|f 1 |D ]'  }		 ||	   |   }
t        |
      D ]  }||	|f|
|   f  ) d y# t        $ r Y lw xY w# t        $ r Y Gw xY ww)a  regenerate original config.

        this is an iterator which yields ``(cat,scheme,option),value`` items,
        in the order they generally appear inside an INI file.
        if interpreted as a dictionary, it should match the original
        keywords passed to the CryptContext (aside from any canonization).

        it's mainly used as the internal backend for most of the public
        serialization methods.
        r|   r   rU   N)
r   r   r   remover   r|   r   r   rY   r   )rr   rf   r   r   scheme_keyscontext_keysr-   r   r   r   rl   s              r.   r   z_CryptConfig.iter_configy  sI     --//^,o. $	*!(dll)4;66 T__, 	<C $ 22+C05E "%. $Uc*E112 & <<)&1#6D  &d| <"FC0$s);;<<	<      sN   BD	C&+D=C5!D&	C2/D1C22D5	D>D DDr   rU   r   r   )%r   r   r   r   r   r   r   r|   r   r  r  r  r  ry   r   r   r   r   r   r   r   r   staticmethodr   r  r   r  r  r   r  r   r)  r-  r1  r    r5  r   r=   r;   r.   r   r   K  s     O  H G J L  H M
&LG4R
&V 35 8, ?A 9  &%V)?V
*U,  .%6)NV$G0 P P.<r;   r   c                   J   e Zd ZdZdZdZdZed        Zed>d       Z	ed>d       Z
d Zd Zd Zded	fd
Zd Zd Zd Z eeed      Zed        Zd?dZd?dZed        Zd Zd@dZdAdZdBdZd Zed        Zed        Z ed        Z!dCdZ"d Z#dDdZ$dZ%d Z&d!Z'd"Z(dZ)d#Z*d$ Z+dEd%Z,d& Z-dFd'Z. e/d(d)d*+      dEd,       Z0 e/d-d).      dEd/       Z1 e/d-d).      dEd0       Z2	 	 dGd1Z3dEd2Z4 e/d-d)d3+      d4        Z5dEd5Z6dEd6Z7d7Z8e9d8        Z:d9 Z;dHd:Z<d; Z=dId<Z>d= Z?y)Jr!   a-  Helper for hashing & verifying passwords using multiple algorithms.

    Instances of this class allow applications to choose a specific
    set of hash algorithms which they wish to support, set limits and defaults
    for the rounds and salt sizes those algorithms should use, flag
    which algorithms should be deprecated, and automatically handle
    migrating users to stronger hashes when they log in.

    Basic usage::

        >>> ctx = CryptContext(schemes=[...])

    See the Passlib online documentation for details and full documentation.
    Nc                     t        |t              r | di |S t        ||       r|S  |        }|j                  |       |S )z2internal helper - accepts string, dict, or contextr=   )rY   rZ   load)rL   rR   rr   s      r.   _norm_sourcezCryptContext._norm_source  sA     fd#== $M5DIIfKr;   c                 z    t        |t              st        |dd       | d      }|j                  |||       |S )a  create new CryptContext instance from an INI-formatted string.

        :type source: unicode or bytes
        :arg source:
            string containing INI-formatted content.

        :type section: str
        :param section:
            option name of section to read from, defaults to ``"passlib"``.

        :type encoding: str
        :arg encoding:
            optional encoding used when source is bytes, defaults to ``"utf-8"``.

        :returns:
            new :class:`CryptContext` instance, configured based on the
            parameters in the *source* string.

        Usage example::

            >>> from passlib.context import CryptContext
            >>> context = CryptContext.from_string('''
            ... [passlib]
            ... schemes = sha256_crypt, des_crypt
            ... sha256_crypt__default_rounds = 30000
            ... ''')

        .. versionadded:: 1.6

        .. seealso:: :meth:`to_string`, the inverse of this constructor.
        zunicode or bytesrR   F	_autoloadrN   rO   )rY   r   r   r=  )rL   rR   rN   rO   rr   s        r.   rQ   zCryptContext.from_string  sA    B &"89#F,>IIU#		&'H	=r;   c                 @     | d      }|j                  |||       |S )a  create new CryptContext instance from an INI-formatted file.

        this functions exactly the same as :meth:`from_string`,
        except that it loads from a local file.

        :type path: str
        :arg path:
            path to local file containing INI-formatted config.

        :type section: str
        :param section:
            option name of section to read from, defaults to ``"passlib"``.

        :type encoding: str
        :arg encoding:
            encoding used to load file, defaults to ``"utf-8"``.

        :returns:
            new CryptContext instance, configured based on the parameters
            stored in the file *path*.

        .. versionadded:: 1.6

        .. seealso:: :meth:`from_string` for an equivalent usage example.
        Fr@  rB  )	load_path)rL   rM   rN   rO   rr   s        r.   rK   zCryptContext.from_path  s%    6 U#tWx@r;   c                 j    t        d      }|j                  |        |r|j                  |d       |S )a6  Return copy of existing CryptContext instance.

        This function returns a new CryptContext instance whose configuration
        is exactly the same as the original, with the exception that any keywords
        passed in will take precedence over the original settings.
        As an example::

            >>> from passlib.context import CryptContext

            >>> # given an existing context...
            >>> ctx1 = CryptContext(["sha256_crypt", "md5_crypt"])

            >>> # copy can be used to make a clone, and update
            >>> # some of the settings at the same time...
            >>> ctx2 = custom_app_context.copy(default="md5_crypt")

            >>> # and the original will be unaffected by the change
            >>> ctx1.default_scheme()
            "sha256_crypt"
            >>> ctx2.default_scheme()
            "md5_crypt"

        .. versionadded:: 1.6
            This method was previously named :meth:`!replace`. That alias
            has been deprecated, and will be removed in Passlib 1.8.

        .. seealso:: :meth:`update`
        Fr@  Trh   )r!   r=  )rr   rl   r  s      r.   r   zCryptContext.copy,  s3    @ u-

4JJtDJ)r;   c                 &     | j                   di |S )zG
        alias for :meth:`copy`, to match PasswordHash.using()
        r=   )r   rr   rl   s     r.   r  zCryptContext.usingR  s     tyy 4  r;   c                 J    t        dt        d        | j                  di |S )z deprecated alias of :meth:`copy`zCryptContext().replace() has been deprecated in Passlib 1.6, and will be removed in Passlib 1.8, it has been renamed to CryptContext().copy()rD   rE   r=   )r   rJ   r   rH  s     r.   rt   zCryptContext.replaceX  s,     <  A	/ tyy 4  r;   Tc                 4   |||d<   |t         urlt        dt               || j                  |       y t	        |t
              r-| j                  |j                         | j                  |       y t        d      |r| j                  |       y |rJ d       y )Nr|   zThe CryptContext ``policy`` keyword has been deprecated as of Passlib 1.6, and will be removed in Passlib 1.8; please use ``CryptContext.from_string()` or ``CryptContext.from_path()`` instead.z%policy must be a CryptPolicy instancez/_autoload=False and kwds are mutually exclusive)	_UNSETr   rJ   r=  rY   r#   ri   rh   r\   )rr   r|   policyrA  rl   s        r.   ry   zCryptContext.__init__c  s     %DO 9 $	%
 ~		$FK0		&//*D! GHHIIdONNNtr;   c                     dt        |       z  S )Nz<CryptContext at 0x%0x>)idr}   s    r.   __repr__zCryptContext.__repr__  s    (2d833r;   c                 8    t        | j                         d      S )NT)rH   ro   )r#   r   r}   s    r.   _get_policyzCryptContext._get_policy  s     TYY[tLLr;   c                     t        dt        d       t        |t              r| j	                  |j
                         y t        d      )NzThe CryptPolicy class and the ``context.policy`` attribute have been deprecated as of Passlib 1.6, and will be removed in Passlib 1.8; please use the ``context.load()`` and ``context.update()`` methods instead.rD   rE   zexpected CryptPolicy instance)r   rJ   rY   r#   r=  ri   r\   )rr   rL  s     r.   _set_policyzCryptContext._set_policy  s>     5  A		/
 fk*IIfoo&;<<r;   zC[deprecated] returns CryptPolicy instance tied to this CryptContext)docc                     t               }t        r|j                  | |       n|j                  | |       t	        |j                  |            S )z<helper read INI from stream, extract passlib section as dict)r   r   	read_filereadfprZ   items)r   rN   filenameps       r.   _parse_ini_streamzCryptContext._parse_ini_stream  sA     KK)HHVX& AGGG$%%r;   c                      fd}t         r t        d|      5 } ||      cddd       S |dv rt        d      5 } ||      cddd       S t        d      5 }|j                         j                  |      j	                  d      } |t        |            cddd       S # 1 sw Y   yxY w# 1 sw Y   yxY w# 1 sw Y   yxY w)a  Load new configuration into CryptContext from a local file.

        This function is a wrapper for :meth:`load` which
        loads a configuration string from the local file *path*,
        instead of an in-memory source. Its behavior and options
        are otherwise identical to :meth:`!load` when provided with
        an INI-formatted string.

        .. versionadded:: 1.6
        c                 P    j                  |       }j                  |      S )NrF  )r[  r=  )r   rl   rM   rN   rr   rh   s     r.   helperz&CryptContext.load_path.<locals>.helper  s*    ))&'4@D99T&911r;   rt)rO   N)r   asciirbr   )r   openreaddecoder   r   )	rr   rM   rh   rN   rO   r^  r   fhtmps	   ````     r.   rD  zCryptContext.load_path  s    	2 dD84 &f~& &++dD! &Vf~& & dD! ,Rggi&&x077@gcl+, ,& && &, ,s#   B*B6!?C*B36B?Cc                    d}t        |t              rAt        rt        ||d      }nt	        |d|d      }| j                  t        |      |d      }nQt        |t              r(t        |j                  j                  d            }d}nt        |d	      st        |d
d      |r)| j                  t        fdt        |      D              }|rG| j                  ;|sy|}t        | j                  j                  d            }|j                  |       t!        |      }|| _	        | j#                          |j$                  | _        |j(                  | _        |j,                  r| j.                  j1                  dd       yd| _        y)a  Load new configuration into CryptContext, replacing existing config.

        :arg source:
            source of new configuration to load.
            this value can be a number of different types:

            * a :class:`!dict` object, or compatible Mapping

                the key/value pairs will be interpreted the same
                keywords for the :class:`CryptContext` class constructor.

            * a :class:`!unicode` or :class:`!bytes` string

                this will be interpreted as an INI-formatted file,
                and appropriate key/value pairs will be loaded from
                the specified *section*.

            * another :class:`!CryptContext` object.

                this will export a snapshot of its configuration
                using :meth:`to_dict`.

        :type update: bool
        :param update:
            By default, :meth:`load` will replace the existing configuration
            entirely. If ``update=True``, it will preserve any existing
            configuration options that are not overridden by the new source,
            much like the :meth:`update` method.

        :type section: str
        :param section:
            When parsing an INI-formatted string, :meth:`load` will look for
            a section named ``"passlib"``. This option allows an alternate
            section name to be used. Ignored when loading from a dictionary.

        :type encoding: str
        :param encoding:
            Encoding to use when **source** is bytes.
            Defaults to ``"utf-8"``. Ignored when loading from a dictionary.

            .. deprecated:: 1.8

                This keyword, and support for bytes input, will be dropped in Passlib 2.0

        :raises TypeError:
            * If the source cannot be identified.
            * If an unknown / malformed keyword is encountered.

        :raises ValueError:
            If an invalid keyword value is encountered.

        .. note::

            If an error occurs during a :meth:`!load` call, the :class:`!CryptContext`
            instance will be restored to the configuration it was in before
            the :meth:`!load` call was made; this is to ensure it is
            *never* left in an inconsistent state due to a load error.

        .. versionadded:: 1.6
        TrR   )paramr   )source_encodingrh  z&<string passed to CryptContext.load()>re   FrX  zstring or dictc              3   8   K   | ]  \  }} |      |f  y wrU   r=   )rV   r   r-   parses      r.   rX   z$CryptContext.load.<locals>.<genexpr>/  s&      ?(c5 !:u- ?   N_strip_unused_context_kwds)rY   r   r   r   r   r[  r   r!   rZ   r   r   r   r   _parse_config_keyr   rh   r   _reset_dummy_verifyr)  _get_recordr1  _identify_recordr  __dict__rw   rm  )	rr   rR   rh   rN   rO   
parse_keysrf  configrk  s	           @r.   r=  zCryptContext.load  sj   @ 
f45#FHHE!&'8(02++N6,BG,TVF-&..44T4BCFJ)#F,<hGG **E ?,5f,=? ?Fdll.C$,,2242@AFMM#
 f%  "!,, & 6 6MM:DA /3D+r;   c                 |   t        | t              sJ | j                  dd      j                  d      }t	        |      }|dk(  r
dd|d   }}}n'|dk(  rd}|\  }}n|dk(  r|\  }}}nt        d|       |d	k(  rd}n|s|t        d
| z        |dk(  rd}n|s|t        d| z        |st        d| z        |||fS )z>helper used to parse ``cat__scheme__option`` keys into a tupler   r   rc   Nr   rD      z'keys must have less than 3 separators: r   zempty category: %rrx   zempty scheme: %rzempty option: %r)rY   r   rt   splitrg   r\   )ckeypartscountr   r   r   s         r.   rn  zCryptContext._parse_config_keyI  s     $ 344S$'--d3E
A:#T58CaZCKFCaZ$C!$ % % )C04788YFF..566.566FCr;   c                     |r=t        |      dkD  rt        d      |rt        d      | j                  |d   d       y|r| j                  |d       yy)a  Helper for quickly changing configuration.

        This acts much like the :meth:`!dict.update` method:
        it updates the context's configuration,
        replacing the original value(s) for the specified keys,
        and preserving the rest.
        It accepts any :ref:`keyword <context-options>`
        accepted by the :class:`!CryptContext` constructor.

        .. versionadded:: 1.6

        .. seealso:: :meth:`copy`
        rc   z(expected at most one positional argumentz.positional arg and keywords mutually exclusiver   TrF  N)rg   r\   r=  rr   rs   rl   s      r.   rh   zCryptContext.updateg  sY     4y1} JKK PQQIId1gdI+IId4I( r;   c                 h      j                   j                  }|rt         fd|D              S |S )a;  return schemes loaded into this CryptContext instance.

        :type resolve: bool
        :arg resolve:
            if ``True``, will return a tuple of :class:`~passlib.ifc.PasswordHash`
            objects instead of their names.

        :returns:
            returns tuple of the schemes configured for this context
            via the *schemes* option.

        .. versionadded:: 1.6
            This was previously available as ``CryptContext().policy.schemes()``

        .. seealso:: the :ref:`schemes <context-schemes-option>` option for usage example.
        c              3   F   K   | ]  }j                  |         yw)r   Nr8   )rV   r   r   rr   r   s     r.   rX   z'CryptContext.schemes.<locals>.<genexpr>  s(      0# fh\R 0s   !)r   r|   r   )rr   rf   r   r   r|   s   ` `` r.   r|   zCryptContext.schemes  s8    . ,,&& 0'.0 0 0 Nr;   c                 J    | j                  d||      }|r|S |j                  S )ah  return name of scheme that :meth:`hash` will use by default.

        :type resolve: bool
        :arg resolve:
            if ``True``, will return a :class:`~passlib.ifc.PasswordHash`
            object instead of the name.

        :type category: str or None
        :param category:
            Optional :ref:`user category <user-categories>`.
            If specified, this will return the catgory-specific default scheme instead.

        :returns:
            name of the default scheme.

        .. seealso:: the :ref:`default <context-default-option>` option for usage example.

        .. versionadded:: 1.6

        .. versionchanged:: 1.7

            This now returns a hasher configured with any CryptContext-specific
            options (custom rounds settings, etc).  Previously this returned
            the base hasher from :mod:`passlib.hash`.
        Nr   )r9   r7   )rr   r   rf   r   hashers        r.   r  zCryptContext.default_scheme  s)    < dH<H v1fkk1r;   c                     	 | j                  ||      }|r|j                  S |S # t        $ r Y nw xY w| j                  j                  rt        d|      t        d      )a  helper to resolve name of scheme -> :class:`~passlib.ifc.PasswordHash` object used by scheme.

        :arg scheme:
            This should identify the scheme to lookup.
            If omitted or set to ``None``, this will return the handler
            for the default scheme.

        :arg category:
            If a user category is specified, and no scheme is provided,
            it will use the default for that category.
            Otherwise this parameter is ignored.

        :param unconfigured:

            By default, this returns a handler object whose .hash()
            and .needs_update() methods will honor the configured
            provided by CryptContext.   See ``unconfigured=True``
            to get the underlying handler from before any context-specific
            configuration was applied.

        :raises KeyError:
            If the scheme does not exist OR is not being used within this context.

        :returns:
            :class:`~passlib.ifc.PasswordHash` object used to implement
            the named scheme within this context (this will usually
            be one of the objects from :mod:`passlib.hash`)

        .. versionadded:: 1.6
            This was previously available as ``CryptContext().policy.get_handler()``

        .. versionchanged:: 1.7

            This now returns a hasher configured with any CryptContext-specific
            options (custom rounds settings, etc).  Previously this returned
            the base hasher from :mod:`passlib.hash`.
        z9crypt algorithm not found in this CryptContext instance: z8no crypt algorithms loaded in this CryptContext instance)rp  r!  r   r   r   )rr   r   r   r   r  s        r.   r9   zCryptContext.handler  sy    L	%%fh7F444 		<<  :@C D D  3 4 4s   $ $ 	00c                 N    t        d | j                  j                  D              S )zCcheck if any handlers in this context aren't in the global registryc              3   6   K   | ]  }t        |      s|  y wrU   )r:   rV   r9   s     r.   rX   z:CryptContext._get_unregistered_handlers.<locals>.<genexpr>2  s      =27;  =s   )r   r   r   r}   s    r.   _get_unregistered_handlersz'CryptContext._get_unregistered_handlers0  s%     =DLL,A,A = = 	=r;   c                 .    | j                   j                  S )z
        return :class:`!set` containing union of all :ref:`contextual keywords <context-keywords>`
        supported by the handlers in this context.

        .. versionadded:: 1.6.6
        )r   r  r}   s    r.   r  zCryptContext.context_kwds5  s     ||(((r;   c                 D    | \  }}}|r|d|xs dd|S |r|d|S |S )z*convert 3-part config key to single stringr   rx   r=   )r   r   r   options       r.   r   zCryptContext._render_config_keyB  s;     "VV#&(;)(;VDD%v..Mr;   c                 H   t        |t        t        f      rdj                  |      }nLt        |t              r<t        |t
              r!| d   dk(  r|rd|z  j                  d      nd}nt        |      }t        |t              sJ d| d|       |j                  dd	      S )
z,render value to string suitable for INI filer   rD   r4   z%.2f0zexpected string for key: rv   r%   z%%)
rY   r   r   r   r   r(   r)   r   r   rt   )r   r-   s     r.   _render_ini_valuezCryptContext._render_ini_valueM  s    
 ed5\*IIe$E y)%'CFm,C8=%//43E
%!45 	?36>	? }}S$''r;   c                 v    | j                   t        fd| j                  j                  |      D              S )ag  Return current configuration as a dictionary.

        :type resolve: bool
        :arg resolve:
            if ``True``, the ``schemes`` key will contain a list of
            a :class:`~passlib.ifc.PasswordHash` objects instead of just
            their names.

        This method dumps the current configuration of the CryptContext
        instance. The key/value pairs should be in the format accepted
        by the :class:`!CryptContext` class constructor, in fact
        ``CryptContext(**myctx.to_dict())`` will create an exact copy of ``myctx``.
        As an example::

            >>> # you can dump the configuration of any crypt context...
            >>> from passlib.apps import ldap_nocrypt_context
            >>> ldap_nocrypt_context.to_dict()
            {'schemes': ['ldap_salted_sha1',
            'ldap_salted_md5',
            'ldap_sha1',
            'ldap_md5',
            'ldap_plaintext']}

        .. versionadded:: 1.6
            This was previously available as ``CryptContext().policy.to_dict()``

        .. seealso:: the :ref:`context-serialization-example` example in the tutorial.
        c              3   8   K   | ]  \  }} |      |f  y wrU   r=   )rV   r   r-   r   s      r.   rX   z'CryptContext.to_dict.<locals>.<genexpr>  s(      I"U  _e, Irl  )r   rZ   r   r   )rr   rf   r   s     @r.   rj   zCryptContext.to_dictb  s=    > ,,
 I&*ll&>&>w&GI I 	Ir;   c                     | j                   }| j                  }|j                  |       | j                  j	                         D ])  \  }} |||      } ||      }|j                  |||       + y)z(helper to write to ConfigParser instanceN)r   r  add_sectionr   r   r   )rr   parserrN   r   r   kvs          r.   _write_to_parserzCryptContext._write_to_parser  sk    ,,
--7#<<++- 	&CAaQ"A1AJJw1%	&r;   c                 :   t               }| j                  ||       t               }|j                  |       | j	                         }|r*|j                  ddj                  d |D              z         |j                         }t        s|j                  d      }|S )aH  serialize to INI format and return as unicode string.

        :param section:
            name of INI section to output, defaults to ``"passlib"``.

        :returns:
            CryptContext configuration, serialized to a INI unicode string.

        This function acts exactly like :meth:`to_dict`, except that it
        serializes all the contents into a single human-readable string,
        which can be hand edited, and/or stored in a file. The
        output of this method is accepted by :meth:`from_string`,
        :meth:`from_path`, and :meth:`load`. As an example::

            >>> # you can dump the configuration of any crypt context...
            >>> from passlib.apps import ldap_nocrypt_context
            >>> print ldap_nocrypt_context.to_string()
            [passlib]
            schemes = ldap_salted_sha1, ldap_salted_md5, ldap_sha1, ldap_md5, ldap_plaintext

        .. versionadded:: 1.6
            This was previously available as ``CryptContext().policy.to_string()``

        .. seealso:: the :ref:`context-serialization-example` example in the tutorial.
        z# NOTE: the %s handler(s) are not registered with Passlib,
# this string may not correctly reproduce the current configuration.

r   c              3   F   K   | ]  }t        |j                          y wrU   )reprr7   r  s     r.   rX   z)CryptContext.to_string.<locals>.<genexpr>  s     MWd7<<0Ms   !r   )	r   r  r   r   r  r   getvaluer   rd  )rr   rN   r  bufunregisteredr   s         r.   r   zCryptContext.to_string  s    4 "#fg.S668II[IIMMMN O lln**W%C
r;      
   rD   r&   r   c                 $    | j                          y rU   )ro  r}   s    r.   reset_min_verify_timez"CryptContext.reset_min_verify_time  s      "r;   c                     |r.t        |t              st        |d      | j                  ||      S | j	                  ||      S )zCreturn record based on scheme, or failing that, by identifying hashr>   )rY   r   r   rp  rq  rr   r>   r   r   s       r.   _get_or_identify_recordz$CryptContext._get_or_identify_record  sE    d$:;)$77##FH55 ((x88r;   c                     |sy| j                   j                  j                  |j                        }|D ]  }|j                  |d        y)af  
        helper which removes any context keywords from **kwds**
        that are known to be used by another scheme in this context,
        but are NOT supported by handler specified by **record**.

        .. note::
            as optimization, load() will set this method to None on a per-instance basis
            if there are no context kwds.
        N)r   r  r   rw   )rr   rl   r*  unused_kwdsr   s        r.   rm  z'CryptContext._strip_unused_context_kwds  sG     ll//::6;N;NO 	 CHHS$	 r;   c                     |t        dt               | j                  |||      }|j                  xs |j	                  ||      S )a	  Check if hash needs to be replaced for some reason,
        in which case the secret should be re-hashed.

        This function is the core of CryptContext's support for hash migration:
        This function takes in a hash string, and checks the scheme,
        number of rounds, and other properties against the current policy.
        It returns ``True`` if the hash is using a deprecated scheme,
        or is otherwise outside of the bounds specified by the policy
        (e.g. the number of rounds is lower than :ref:`min_rounds <context-min-rounds-option>`
        configuration for that algorithm).
        If so, the password should be re-hashed using :meth:`hash`
        Otherwise, it will return ``False``.

        :type hash: unicode or bytes
        :arg hash:
            The hash string to examine.

        :type scheme: str or None
        :param scheme:

            Optional scheme to use. Scheme must be one of the ones
            configured for this context (see the
            :ref:`schemes <context-schemes-option>` option).
            If no scheme is specified, it will be identified
            based on the value of *hash*.

            .. deprecated:: 1.7

                Support for this keyword is deprecated, and will be removed in Passlib 2.0.

        :type category: str or None
        :param category:
            Optional :ref:`user category <user-categories>`.
            If specified, this will cause any category-specific defaults to
            be used when determining if the hash needs to be updated
            (e.g. is below the minimum rounds).

        :type secret: unicode, bytes, or None
        :param secret:
            Optional secret associated with the provided ``hash``.
            This is not required, or even currently used for anything...
            it's for forward-compatibility with any future
            update checks that might need this information.
            If provided, Passlib assumes the secret has already been
            verified successfully against the hash.

            .. versionadded:: 1.6

        :returns: ``True`` if hash should be replaced, otherwise ``False``.

        :raises ValueError:
            If the hash did not match any of the configured :meth:`schemes`.

        .. versionadded:: 1.6
            This method was previously named :meth:`hash_needs_update`.

        .. seealso:: the :ref:`context-migration-example` example in the tutorial.
        zqCryptContext.needs_update(): 'scheme' keyword is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0r?   )r   rJ   r  r   needs_update)rr   r>   r   r   r?   r*  s         r.   r  zCryptContext.needs_update  sU    v   C#% --dFHE  LF$7$7V$7$LLr;   z1.6z2.0zCryptContext.needs_update())r   removedreplacementc                 (    | j                  |||      S )a  Legacy alias for :meth:`needs_update`.

        .. deprecated:: 1.6
            This method was renamed to :meth:`!needs_update` in version 1.6.
            This alias will be removed in version 2.0, and should only
            be used for compatibility with Passlib 1.3 - 1.5.
        )r  r  s       r.   hash_needs_updatezCryptContext.hash_needs_updateF  s       vx88r;   z1.7)r   r  c                 x    | j                  ||      }| j                  }|r	 |||        |j                  di |S )zGenerate a config string for specified scheme.

        .. deprecated:: 1.7

            This method will be removed in version 2.0, and should only
            be used for compatibility with Passlib 1.3 - 1.6.
        r=   )rp  rm  	genconfig)rr   r   r   r"  r*  strip_unuseds         r.   r  zCryptContext.genconfigQ  sD     !!&(3666*v+(++r;   c                 ~    | j                  |||      }| j                  }|r	 |||        |j                  ||fi |S )zGenerate hash for the specified secret using another hash.

        .. deprecated:: 1.7

            This method will be removed in version 2.0, and should only
            be used for compatibility with Passlib 1.3 - 1.6.
        )r  rm  genhash)rr   r?   rt  r   r   rl   r*  r  s           r.   r  zCryptContext.genhash`  sH     --ffhG66v&v~~ff555r;   c                 j    | j                  |||      }|y|r|r|j                  S |S |j                  S )a  Attempt to identify which algorithm the hash belongs to.

        Note that this will only consider the algorithms
        currently configured for this context
        (see the :ref:`schemes <context-schemes-option>` option).
        All registered algorithms will be checked, from first to last,
        and whichever one positively identifies the hash first will be returned.

        :type hash: unicode or bytes
        :arg hash:
            The hash string to test.

        :type category: str or None
        :param category:
            Optional :ref:`user category <user-categories>`.
            Ignored by this function, this parameter
            is provided for symmetry with the other methods.

        :type resolve: bool
        :param resolve:
            If ``True``, returns the hash handler itself,
            instead of the name of the hash.

        :type required: bool
        :param required:
            If ``True``, this will raise a ValueError if the hash
            cannot be identified, instead of returning ``None``.

        :returns:
            The handler which first identifies the hash,
            or ``None`` if none of the algorithms identify the hash.
        N)rq  r!  r7   )rr   r>   r   rf   r   r   r*  s          r.   r/  zCryptContext.identifyo  sB    D &&tXx@>444;;r;   c                     |t        dt               | j                  ||      }| j                  }|r	 |||        |j                  |fi |S )aZ  run secret through selected algorithm, returning resulting hash.

        :type secret: unicode or bytes
        :arg secret:
            the password to hash.

        :type scheme: str or None
        :param scheme:

            Optional scheme to use. Scheme must be one of the ones
            configured for this context (see the
            :ref:`schemes <context-schemes-option>` option).
            If no scheme is specified, the configured default
            will be used.

            .. deprecated:: 1.7

                Support for this keyword is deprecated, and will be removed in Passlib 2.0.

        :type category: str or None
        :param category:
            Optional :ref:`user category <user-categories>`.
            If specified, this will cause any category-specific defaults to
            be used when hashing the password (e.g. different default scheme,
            different default rounds values, etc).

        :param \*\*kwds:
            All other keyword options are passed to the selected algorithm's
            :meth:`PasswordHash.hash() <passlib.ifc.PasswordHash.hash>` method.

        :returns:
            The secret as encoded by the specified algorithm and options.
            The return value will always be a :class:`!str`.

        :raises TypeError, ValueError:
            * If any of the arguments have an invalid type or value.
              This includes any keywords passed to the underlying hash's
              :meth:`PasswordHash.hash() <passlib.ifc.PasswordHash.hash>` method.

        .. seealso:: the :ref:`context-basic-example` example in the tutorial
        ziCryptContext.hash(): 'scheme' keyword is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0)r   rJ   rp  rm  r>   )rr   r?   r   r   rl   r*  r  s          r.   r>   zCryptContext.hash  s`    V   C#% !!&(366v&v{{6*T**r;   zCryptContext.hash()c                 &     | 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|  s      r.   encryptzCryptContext.encrypt  s     tyy$'$''r;   c                     |t        dt               || j                          y| j                  |||      }| j                  }|r	 |||        |j
                  ||fi |S )a  verify secret against an existing hash.

        If no scheme is specified, this will attempt to identify
        the scheme based on the contents of the provided hash
        (limited to the schemes configured for this context).
        It will then check whether the password verifies against the hash.

        :type secret: unicode or bytes
        :arg secret:
            the secret to verify

        :type hash: unicode or bytes
        :arg hash:
            hash string to compare to

            if ``None`` is passed in, this will be treated as "never verifying"

        :type scheme: str
        :param scheme:
            Optionally force context to use specific scheme.
            This is usually not needed, as most hashes can be unambiguously
            identified. Scheme must be one of the ones configured
            for this context
            (see the :ref:`schemes <context-schemes-option>` option).

            .. deprecated:: 1.7

                Support for this keyword is deprecated, and will be removed in Passlib 2.0.

        :type category: str or None
        :param category:
            Optional :ref:`user category <user-categories>` string.
            This is mainly used when generating new hashes, it has little
            effect when verifying; this keyword is mainly provided for symmetry.

        :param \*\*kwds:
            All additional keywords are passed to the appropriate handler,
            and should match its :attr:`~passlib.ifc.PasswordHash.context_kwds`.

        :returns:
            ``True`` if the password matched the hash, else ``False``.

        :raises ValueError:
            * if the hash did not match any of the configured :meth:`schemes`.

            * if any of the arguments have an invalid value (this includes
              any keywords passed to the underlying hash's
              :meth:`PasswordHash.verify() <passlib.ifc.PasswordHash.verify>` method).

        :raises TypeError:
            * if any of the arguments have an invalid type (this includes
              any keywords passed to the underlying hash's
              :meth:`PasswordHash.verify() <passlib.ifc.PasswordHash.verify>` method).

        .. seealso:: the :ref:`context-basic-example` example in the tutorial
        kCryptContext.verify(): 'scheme' keyword is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0F)r   rJ   dummy_verifyr  rm  verify)rr   r?   r>   r   r   rl   r*  r  s           r.   r  zCryptContext.verify  sz    v   C#% < --dFHE66v&v}}VT2T22r;   c                 b   |t        dt               || j                          y| j                  |||      }| j                  }|r|r|j                         } |||       n|} |j                  ||fi |sy|j                  s|j                  ||      rd | j                  |fd|i|fS y)a
  verify password and re-hash the password if needed, all in a single call.

        This is a convenience method which takes care of all the following:
        first it verifies the password (:meth:`~CryptContext.verify`), if this is successfull
        it checks if the hash needs updating (:meth:`~CryptContext.needs_update`), and if so,
        re-hashes the password (:meth:`~CryptContext.hash`), returning the replacement hash.
        This series of steps is a very common task for applications
        which wish to update deprecated hashes, and this call takes
        care of all 3 steps efficiently.

        :type secret: unicode or bytes
        :arg secret:
            the secret to verify

        :type secret: unicode or bytes
        :arg hash:
            hash string to compare to.

            if ``None`` is passed in, this will be treated as "never verifying"

        :type scheme: str
        :param scheme:
            Optionally force context to use specific scheme.
            This is usually not needed, as most hashes can be unambiguously
            identified. Scheme must be one of the ones configured
            for this context
            (see the :ref:`schemes <context-schemes-option>` option).

            .. deprecated:: 1.7

                Support for this keyword is deprecated, and will be removed in Passlib 2.0.

        :type category: str or None
        :param category:
            Optional :ref:`user category <user-categories>`.
            If specified, this will cause any category-specific defaults to
            be used if the password has to be re-hashed.

        :param \*\*kwds:
            all additional keywords are passed to the appropriate handler,
            and should match that hash's
            :attr:`PasswordHash.context_kwds <passlib.ifc.PasswordHash.context_kwds>`.

        :returns:
            This function returns a tuple containing two elements:
            ``(verified, replacement_hash)``. The first is a boolean
            flag indicating whether the password verified,
            and the second an optional replacement hash.
            The tuple will always match one of the following 3 cases:

            * ``(False, None)`` indicates the secret failed to verify.
            * ``(True, None)`` indicates the secret verified correctly,
              and the hash does not need updating.
            * ``(True, str)`` indicates the secret verified correctly,
              but the current hash needs to be updated. The :class:`!str`
              will be the freshly generated hash, to replace the old one.

        :raises TypeError, ValueError:
            For the same reasons as :meth:`verify`.

        .. seealso:: the :ref:`context-migration-example` example in the tutorial.
        r  )FNr  Tr   )TN)
r   rJ   r  r  rm  r   r  r   r  r>   )	rr   r?   r>   r   r   rl   r*  r  
clean_kwdss	            r.   verify_and_updatezCryptContext.verify_and_update-	  s    @  C#% < --dFHE66DJV,J
 v}}VT8Z8&"5"5d6"5"J6EHEEEEr;   ztoo many secretsc                 8    | j                  | j                        S )z>
        precalculated hash for dummy_verify() to use
        )r>   _dummy_secretr}   s    r.   _dummy_hashzCryptContext._dummy_hash	  s    
 yy++,,r;   c                 L    t        |       j                  j                  |        y)z>
        flush memoized values used by dummy_verify()
        N)r]   r  clear_cacher}   s    r.   ro  z CryptContext._reset_dummy_verify	  s     	T
**40r;   c                 P    | j                  | j                  | j                         y)a  
        Helper that applications can call when user wasn't found,
        in order to simulate time it would take to hash a password.

        Runs verify() against a dummy hash, to simulate verification
        of a real account password.

        :param elapsed:

            .. deprecated:: 1.7.1

                this option is ignored, and will be removed in passlib 1.8.

        .. versionadded:: 1.7
        F)r  r  r  )rr   elapseds     r.   r  zCryptContext.dummy_verify	  s!      	D&&(8(89r;   c                 <    | j                  |d      j                   S )an  
        test if hash represents a usuable password --
        i.e. does not represent an unusuable password such as ``"!"``,
        which is recognized by the :class:`~passlib.hash.unix_disabled` hash.

        :raises ValueError:
            if the hash is not recognized
            (typically solved by adding ``unix_disabled`` to the list of schemes).
        N)rq  r3  )rr   r>   s     r.   
is_enabledzCryptContext.is_enabled	  s      ((t4@@@@r;   c                 l    | j                   j                  }|j                  sJ |j                  |      S )a  
        return a string to disable logins for user,
        usually by returning a non-verifying string such as ``"!"``.

        :param hash:
            Callers can optionally provide the account's existing hash.
            Some disabled handlers (such as :class:`!unix_disabled`)
            will encode this into the returned value,
            so that it can be recovered via :meth:`enable`.

        :raises RuntimeError:
            if this function is called w/o a disabled hasher
            (such as :class:`~passlib.hash.unix_disabled`) included
            in the list of schemes.

        :returns:
            hash string which will be recognized as valid by the context,
            but is guaranteed to not validate against *any* password.
        )r   r5  r3  disablerr   r>   r*  s      r.   r  zCryptContext.disable	  s.    ( --!!!~~d##r;   c                 d    | j                  |d      }|j                  r|j                  |      S |S )a  
        inverse of :meth:`disable` --
        attempts to recover original hash which was converted
        by a :meth:`!disable` call into a disabled hash --
        thus restoring the user's original password.

        :raises ValueError:
            if original hash not present, or if the disabled handler doesn't
            support encoding the original hash (e.g. ``django_disabled``)

        :returns:
            the original hash.
        N)rq  r3  enabler  s      r.   r  zCryptContext.enable	  s5     &&tT2==&& Kr;   r   )Fr   r   )FNF)NFFr   r   r   )NN)NNN)NFFF)r   rU   )@r   r   r   r   r   rp  rq  r   r>  rQ   rK   r   r  rt   rK  ry   rO  rQ  rS  propertyrL  r:  r[  rD  r=  rn  rh   r|   r  r9   r  r  r   r  rj   r  r   mvt_estimate_max_samplesmvt_estimate_min_samplesmvt_estimate_max_timemvt_estimate_resolutionr   r   r  r  rm  r  r   r  r  r  r/  r>   r  r  r  r  r    r  ro  r  r  r  r  r=   r;   r.   r!   r!     sD   @ G K
 	 	 $ $L  <$L!!  $OD4M	= k;45F & &,8q3f    :)J<2b34j=
 ) )   ( ((!IF&'z  "!"MO#(9  CMJ %Dab9 c9 %7, 8, %76 86 EJ#+Z6+p %DYZ	( [	(K3ZZB 'M- -1.
A$0r;   r!   c                   4     e Zd ZdZdZddZ fdZd Z xZS )r"   a  CryptContext subclass which doesn't load handlers until needed.

    This is a subclass of CryptContext which takes in a set of arguments
    exactly like CryptContext, but won't import any handlers
    (or even parse its arguments) until
    the first time one of its methods is accessed.

    :arg schemes:
        The first positional argument can be a list of schemes, or omitted,
        just like CryptContext.

    :param onload:

        If a callable is passed in via this keyword,
        it will be invoked at lazy-load time
        with the following signature:
        ``onload(**kwds) -> kwds``;
        where ``kwds`` is all the additional kwds passed to LazyCryptContext.
        It should perform any additional deferred initialization,
        and return the final dict of options to be passed to CryptContext.

        .. versionadded:: 1.6

    :param create_policy:

        .. deprecated:: 1.6
            This option will be removed in Passlib 1.8,
            applications should use ``onload`` instead.

    :param kwds:

        All additional keywords are passed to CryptContext;
        or to the *onload* function (if provided).

    This is mainly used internally by modules such as :mod:`passlib.apps`,
    which define a large number of contexts, but only a few of them will be needed
    at any one time. Use of this class saves the memory needed to import
    the specified handlers until the context instance is actually accessed.
    As well, it allows constructing a context at *module-init* time,
    but using :func:`!onload()` to provide dynamic configuration
    at *application-run* time.

    .. note:: 
        This class is only useful if you're referencing handler objects by name,
        and don't want them imported until runtime. If you want to have the config
        validated before your application runs, or are passing in already-imported
        handler instances, you should use :class:`CryptContext` instead.

    .. versionadded:: 1.4
    Nc                      |||d<   || _         y )Nr|   )
_lazy_kwds)rr   r|   rl   s      r.   ry   zLazyCryptContext.__init__-
  s    %DOr;   c                 V   | j                   }d|v r[t        dt               |j                  d      } |di |}t        j                  |d      }|j                  j                         }nd|v r|j                  d      } |di |}| ` t        t        | *  di | t        | _        y )Ncreate_policyzThe CryptPolicy class, and LazyCryptContext's ``create_policy`` keyword have been deprecated as of Passlib 1.6, and will be removed in Passlib 1.8; please use the ``onload`` keyword instead.Frd   onloadr=   )r  r   rJ   rw   r#   ra   ri   rj   superr"   ry   r!   	__class__)rr   rl   r  resultrL  r  r  s         r.   
_lazy_initzLazyCryptContext._lazy_init2
  s    d" > $	%
 !HH_5M"*T*F ,,V5,AF??**,DXXh'F>D>DO.66%r;   c                     |j                  d      r|j                  d      r| j                  | j                          t        j	                  | |      S )N_r   )
startswithr  r  object__getattribute__)rr   attrs     r.   r  z!LazyCryptContext.__getattribute__E
  s@    $(=OO'!&&tT22r;   rU   )	r   r   r   r   r  ry   r  r  __classcell__)r  s   @r.   r"   r"   	  s    1d J
&&3r;   r"   rU   )Br   
__future__r   r  logging	getLoggerr   log	threadingtimewarningsr   r   r   passlib.excr   r   r   passlib.registryr	   r
   passlib.utilsr   r   r   r   r   r   r   r   r   passlib.utils.binaryr   passlib.utils.compatr   r   r   r   r   r   r   r   r   r   r   passlib.utils.decorr   r    __all__r  rK  r/   r   r   rZ   r*   r   r:   r:  r@   r   rI   r#   r   r!   r"   r=   r;   r.   <module>r     s   3 & 	 'g''1     T T F   .$ $ $ $
 E 
  M  # <   (-89 
A	j& jf\	<6 \	<J|6 |D*W3| W3r;   