§
    HŠtjp  ã                   ót  — d Z ddlmZmZmZmZ ddlZddlmZ 	 ddl	m
Z
 n# e$ r	 ddlm
Z
 Y nw xY wddlmZm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mZmZmZ dd	lmZmZmZ dd
l m!Z! g d¢Z" e#ddddd¬¦  «        Z$d„ Z%d„ Z&d)d„Z'e(e)fZ*e+e,fZ- e+¦   «         Z.d*d„Z/ G d„ de0¦  «        Z1 e#dddd¬¦  «        Z2 G d„ de1¦  «        Z3d+d „Z4d!„ Z5 G d"„ d#e
¦  «        Z6 e6¦   «         Z7d$ 8                    ¦   «         D ]Z9e7 :                    e9d%e9z  ¦  «         Œ G d&„ d'e1¦  «        Z;d+d(„Z<dS ),z*passlib.pwd -- password generation helpersé    )Úabsolute_importÚdivisionÚprint_functionÚunicode_literalsN)Údefaultdict)ÚMutableMapping)ÚceilÚlog)Úexc)ÚPY2ÚirangeÚ
itervaluesÚ	int_types)ÚrngÚ
getrandstrÚ
to_unicode)Úmemoized_property)ÚgenwordÚdefault_charsetsÚ	genphraseÚdefault_wordsetsé   é   é$   é0   é<   )ÚunsafeÚweakÚfairÚstrongÚsecurec                 ój   — t          | ¦  «        j        }||                     |¦  «        dz   d…         S )z2return remaining classes in object's MRO after clsé   N)ÚtypeÚ__mro__Úindex)ÚobjÚclsÚmros      úI/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/passlib/pwd.pyÚ_superclassesr+   8   s0   € å
ˆs‰)Œ)Ô
€CØˆs�yŠy˜‰~Œ~˜aÑÐ Ð Ô!Ð!ó    c                 óf  — 	 t          | ¦  «        }n# t          $ r d}Y nw xY wt          t          ¦  «        }| D ]}||xx         dz  cc<   Œ|€$|                     ¦   «         }t          |¦  «        }nt          |¦  «        }|sdS t          |d¦  «        t          d„ |D ¦   «         ¦  «        |z  z
  S )a÷  
    returns 'rate of self-information' --
    i.e. average (per-symbol) entropy of the sequence **source**,
    where probability of a given symbol occurring is calculated based on
    the number of occurrences within the sequence itself.

    if all elements of the source are unique, this should equal ``log(len(source), 2)``.

    :arg source:
        iterable containing 0+ symbols
        (e.g. list of strings or ints, string of characters, etc).

    :returns:
        float bits of entropy
    Nr#   r   é   c              3   ó<   K  — | ]}|t          |d ¦  «        z  V — ŒdS )r.   N)Úlogf)Ú.0Úvalues     r*   ú	<genexpr>z"_self_info_rate.<locals>.<genexpr>_   s/   è è € ÐJÐJ¸%˜u¥t¨E°1¡~¤~Ñ5ÐJÐJÐJÐJÐJÐJr,   )ÚlenÚ	TypeErrorr   ÚintÚvaluesÚsumr   r0   )ÚsourceÚsizeÚcountsÚcharr7   s        r*   Ú_self_info_rater=   >   sØ   € ð Ý�6‰{Œ{ˆˆøÝð ð ð àˆˆˆðøøøõ �ÑÔ€FØð ð ˆØˆtˆˆŒ˜Ñˆˆ‰ˆØ€|Ø—’‘”ˆÝ�6‰{Œ{ˆˆå˜FÑ#Ô#ˆØð Øˆqõ ��a‰=Œ=�3ÐJÐJÀ6ÐJÑJÔJÑJÔJÈTÑQÑQÐQs   ‚ ’! !c                 ó<  — |r* t          j        |¦  «        t          | ¦  «        ¦  «        S t          j                             | ¦  «        rt          | d¦  «        S |                      d¦  «        \  }}}|st          d| ›�¦  «        ‚t          j
        ||¦  «        S )a  
    :param asset_path:
        string containing absolute path to file,
        or package-relative path using format
        ``"python.module:relative/file/path"``.

    :returns:
        filehandle opened in 'rb' mode
        (unless encoding explicitly specified)
    Úrbú:zIasset path must be absolute file path or use 'pkg.name:sub/path' format: )ÚcodecsÚ	getreaderÚ_open_asset_pathÚosÚpathÚisabsÚopenÚ	partitionÚ
ValueErrorÚpkg_resourcesÚresource_stream)rE   ÚencodingÚpackageÚsepÚsubpaths        r*   rC   rC   j   s­   € ð ð BØ)�vÔ Ñ)Ô)Õ*:¸4Ñ*@Ô*@ÑAÔAÐAÝ	„w‡}‚}�TÑÔð  Ý�D˜$ÑÔÐØ ŸNšN¨3Ñ/Ô/Ñ€GˆS�'Øð LÝˆjØDHÀDðKñ Lô Lð 	LåÔ(¨°'Ñ:Ô:Ð:r,   r9   c                 ó´  — t           }d}	 | |v rdS n# t          $ r d}Y nw xY wt          | t          ¦  «        s-t	          t          | ¦  «        ¦  «        t	          | ¦  «        k    r+|r'	 |                     | ¦  «         n# t          $ r Y nw xY wdS t          ¦   «         }t          ¦   «         }| D ]}||v r|n|                     |¦  «         Œt          |¦  «        }d}t	          |¦  «        |k    rd}d                     d„ |d|…         D ¦   «         ¦  «        }t	          |¦  «        |k    r|dt	          |¦  «        |z
  z  z  }t          d	|›d
|›�¦  «        ‚)z¯
    helper for generators --
    Throws ValueError if source elements aren't unique.
    Error message will display (abbreviated) repr of the duplicates in a string/list
    TFé   é   ú, c              3   óN   K  — | ] }t          t          |¦  «        ¦  «        V — Œ!d S ©N)ÚreprÚstr©r1   Úwords     r*   r3   z!_ensure_unique.<locals>.<genexpr>«   s.   è è € ÐBÐB¨T��c $™iœi™œÐBÐBÐBÐBÐBÐBr,   Nz, ... plus %d othersú`z%` cannot contain duplicate elements: )
Ú_ensure_unique_cacher5   Ú
isinstanceÚ
_set_typesr4   ÚsetÚaddÚsortedÚjoinrI   )	r9   ÚparamÚcacheÚhashableÚseenÚdupsÚelemÚtruncÚdup_reprs	            r*   Ú_ensure_uniquerj   ˆ   s­  € õ !€EØ€HðØ�Uˆ?ˆ?Ø�4ð øåð ð ð Øˆˆˆðøøøõ �&�*Ñ%Ô%ð ­­S°©[¬[Ñ)9Ô)9½SÀ¹[¼[Ò)HÐ)HØð 	ðØ—	’	˜&Ñ!Ô!Ð!Ð!øÝð ð ð ð �ðøøøð ˆtõ ‰5Œ5€DÝ‰5Œ5€DØð 3ð 3ˆØ˜��ˆˆ 4×,Ò,¨TÑ2Ô2Ð2Ð2Ý�$‰<Œ<€DØ€EÝ
ˆ4�y„y�5ÒÐØˆØ�yŠyÐBÐB°T¸&¸5¸&´\ÐBÑBÔBÑBÔB€HÝ
ˆ4�y„y�5ÒÐØÐ*­c°$©i¬i¸%Ñ.?Ñ@Ñ@ˆõ ˆ*Ø�e�e˜X˜Xð'ñ (ô (ð (s   ‹ ’! !Á)A? Á?
BÂBc                   ó†   ‡ — e Zd ZdZdZdZeZdZdˆ fd„	Ze	d„ ¦   «         Z
e	d„ ¦   «         Zd„ Zdd„Zd	„ Zerd
„ Zˆ xZS ˆ xZS )ÚSequenceGeneratoraY  
    Base class used by word & phrase generators.

    These objects take a series of options, corresponding
    to those of the :func:`generate` function.
    They act as callables which can be used to generate a password
    or a list of 1+ passwords. They also expose some read-only
    informational attributes.

    Parameters
    ----------
    :param entropy:
        Optionally specify the amount of entropy the resulting passwords
        should contain (as measured with respect to the generator itself).
        This will be used to auto-calculate the required password size.

    :param length:
        Optionally specify the length of password to generate,
        measured as count of whatever symbols the subclass uses (characters or words).
        Note if ``entropy`` requires a larger minimum length,
        that will be used instead.

    :param rng:
        Optionally provide a custom RNG source to use.
        Should be an instance of :class:`random.Random`,
        defaults to :class:`random.SystemRandom`.

    Attributes
    ----------
    .. autoattribute:: length
    .. autoattribute:: symbol_count
    .. autoattribute:: entropy_per_symbol
    .. autoattribute:: entropy

    Subclassing
    -----------
    Subclasses must implement the ``.__next__()`` method,
    and set ``.symbol_count`` before calling base ``__init__`` method.
    Nr    c                 óH  •— | j         €
J d¦   «         ‚|€|€g|€| j        }t                               ||¦  «        }|dk    rt	          d¦  «        ‚t          t          || j        z  ¦  «        ¦  «        }|�||k     r|}|| _        |dk     rt	          d¦  «        ‚|| _        |�|| _	        |rVt          | t          ¦  «        t          fk    r7t          dd                     |                     ¦   «         ¦  «        z  ¦  «        ‚ t!          t          | ¦  «        j        di |¤Ž d S )	Nzsubclass must set .symbol_countr   z!`entropy` must be positive numberr#   z!`length` must be positive integerzUnexpected keyword(s): %srS   © )Úsymbol_countÚrequested_entropyÚentropy_aliasesÚgetrI   r6   r	   Úentropy_per_symbolÚlengthr   r+   rl   Úobjectr5   ra   ÚkeysÚsuperÚ__init__)ÚselfÚentropyrt   r   ÚkwdsÚ
min_lengthÚ	__class__s         €r*   rx   zSequenceGenerator.__init__ñ   s=  ø€ ð Ô Ð,Ð,Ð.OÑ,Ô,Ð,ð Ð & .ØˆØÔ0�Ý%×)Ò)¨'°7Ñ;Ô;ˆGØ˜!Š|ˆ|Ý Ð!DÑEÔEÐEÝ�T '¨DÔ,CÑ"CÑDÔDÑEÔEˆJØˆ~ ¨*Ò!4Ð!4Ø#�à!(ˆÔà�AŠ:ˆ:ÝÐ@ÑAÔAÐAØˆŒð ˆ?ØˆDŒHð ð 	R•M $Õ(9Ñ:Ô:½v¸iÒGÐGÝÐ7¸$¿)º)ÀDÇIÂIÁKÄKÑ:PÔ:PÑPÑQÔQÐQØ/�Õ Ñ&Ô&Ô/Ð7Ð7°$Ð7Ð7Ð7Ð7Ð7r,   c                 ó,   — t          | j        d¦  «        S )zZ
        Average entropy per symbol (assuming all symbols have equal probability)
        r.   )r0   ro   ©ry   s    r*   rs   z$SequenceGenerator.entropy_per_symbol  s   € õ
 �DÔ% qÑ)Ô)Ð)r,   c                 ó    — | j         | j        z  S )a+  
        Effective entropy of generated passwords.

        This value will always be a multiple of :attr:`entropy_per_symbol`.
        If entropy is specified in constructor, :attr:`length` will be chosen so
        so that this value is the smallest multiple >= :attr:`requested_entropy`.
        )rt   rs   r   s    r*   rz   zSequenceGenerator.entropy  s   € ð Œ{˜TÔ4Ñ4Ð4r,   c                 ó    — t          d¦  «        ‚)z;main generation function, should create one password/phrasezimplement in subclass)ÚNotImplementedErrorr   s    r*   Ú__next__zSequenceGenerator.__next__)  s   € å!Ð"9Ñ:Ô:Ð:r,   c                 óÈ   ‡ — |€t          ‰ ¦  «        S t          |t          ¦  «        rˆ fd„t          |¦  «        D ¦   «         S |t          u r‰ S t          j        |dd¦  «        ‚)zN
        frontend used by genword() / genphrase() to create passwords
        Nc                 ó.   •— g | ]}t          ‰¦  «        ‘ŒS rn   )Únext©r1   Ú_ry   s     €r*   ú
<listcomp>z.SequenceGenerator.__call__.<locals>.<listcomp>4  s   ø€ Ð8Ð8Ð8 1•D˜‘J”JÐ8Ð8Ð8r,   z<None>, int, or <iter>Úreturns)r†   r\   r   r   Úiterr   ÚExpectedTypeError)ry   rŠ   s   ` r*   Ú__call__zSequenceGenerator.__call__-  sm   ø€ ð ˆ?Ý˜‘:”:ÐÝ˜¥Ñ+Ô+ð 	VØ8Ð8Ð8Ð8­¨w©¬Ð8Ñ8Ô8Ð8Ø�ˆ_ˆ_ØˆKåÔ'¨Ð1IÈ9ÑUÔUÐUr,   c                 ó   — | S rU   rn   r   s    r*   Ú__iter__zSequenceGenerator.__iter__:  s   € Øˆr,   c                 ó*   — |                       ¦   «         S rU   )rƒ   r   s    r*   r†   zSequenceGenerator.next>  s   € Ø—=’=‘?”?Ð"r,   ©NNNrU   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rt   rp   r   ro   rx   r   rs   rz   rƒ   r�   r�   r   r†   Ú__classcell__©r}   s   @r*   rl   rl   ¶   s  ø€ € € € € ð&ð &ðX €Fð !Ðð €Cð €Lð
8ð 8ð 8ð 8ð 8ð 8ðF ð*ð *ñ Ôð*ð ð5ð 5ñ Ôð5ð;ð ;ð ;ðVð Vð Vð Vðð ð ð ð #ð	#ð 	#ð 	#ð 	#ð 	#ð 	#ð 	#ð#ð #ð #ð #r,   rl   zH0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*?/Ú>0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZÚ2234679abcdefghjkmnpqrstuvwxyzACDEFGHJKMNPQRTUVWXYZÚ0123456789abcdef)Úascii_72Úascii_62Úascii_50Úhexc                   óH   ‡ — e Zd ZdZdZdZdˆ fd„	Zed„ ¦   «         Zd„ Z	ˆ xZ
S )ÚWordGeneratoraê  
    Class which generates passwords by randomly choosing from a string of unique characters.

    Parameters
    ----------
    :param chars:
        custom character string to draw from.

    :param charset:
        predefined charset to draw from.

    :param \*\*kwds:
        all other keywords passed to the :class:`SequenceGenerator` parent class.

    Attributes
    ----------
    .. autoattribute:: chars
    .. autoattribute:: charset
    .. autoattribute:: default_charsets
    rœ   Nc                 ó  •— |r|rt          d¦  «        ‚n|s| j        }|sJ ‚t          |         }|| _        t          |d¬¦  «        }t	          |d¬¦  «         || _         t          t          | ¦  «        j        di |¤Ž d S )Nz,`chars` and `charset` are mutually exclusiveÚchars©rb   rn   )	r5   Úcharsetr   r   rj   r¢   rw   r    rx   )ry   r¢   r¤   r{   r}   s       €r*   rx   zWordGenerator.__init__~  s­   ø€ ð ð 	.Øð PÝÐ NÑOÔOÐOðPð ð Øœ,�Ø���wÝ$ WÔ-ˆEØˆŒÝ˜5¨Ð0Ñ0Ô0ˆÝ�u GÐ,Ñ,Ô,Ð,ØˆŒ
ð 	,��m˜TÑ"Ô"Ô+Ð3Ð3¨dÐ3Ð3Ð3Ð3Ð3r,   c                 ó*   — t          | j        ¦  «        S rU   )r4   r¢   r   s    r*   ro   zWordGenerator.symbol_count–  ó   € å�4”:‰ŒÐr,   c                 óB   — t          | j        | j        | j        ¦  «        S rU   )r   r   r¢   rt   r   s    r*   rƒ   zWordGenerator.__next__ž  s   € õ ˜$œ( D¤J°´Ñ<Ô<Ð<r,   )NN)r’   r“   r”   r•   r¤   r¢   rx   r   ro   rƒ   r–   r—   s   @r*   r    r    \  s€   ø€ € € € € ðð ð2 €Gð €Eð
4ð 4ð 4ð 4ð 4ð 4ð0 ðð ñ Ôðð=ð =ð =ð =ð =ð =ð =r,   r    c                 ó6   — t          d|| dœ|¤Ž} ||¦  «        S )a¶
  Generate one or more random passwords.

    This function uses :mod:`random.SystemRandom` to generate
    one or more passwords using various character sets.
    The complexity of the password can be specified
    by size, or by the desired amount of entropy.

    Usage Example::

        >>> # generate a random alphanumeric string with 48 bits of entropy (the default)
        >>> from passlib import pwd
        >>> pwd.genword()
        'DnBHvDjMK6'

        >>> # generate a random hexadecimal string with 52 bits of entropy
        >>> pwd.genword(entropy=52, charset="hex")
        '310f1a7ac793f'

    :param entropy:
        Strength of resulting password, measured in 'guessing entropy' bits.
        An appropriate **length** value will be calculated
        based on the requested entropy amount, and the size of the character set.

        This can be a positive integer, or one of the following preset
        strings: ``"weak"`` (24), ``"fair"`` (36),
        ``"strong"`` (48), and ``"secure"`` (56).

        If neither this or **length** is specified, **entropy** will default
        to ``"strong"`` (48).

    :param length:
        Size of resulting password, measured in characters.
        If omitted, the size is auto-calculated based on the **entropy** parameter.

        If both **entropy** and **length** are specified,
        the stronger value will be used.

    :param returns:
        Controls what this function returns:

        * If ``None`` (the default), this function will generate a single password.
        * If an integer, this function will return a list containing that many passwords.
        * If the ``iter`` constant, will return an iterator that yields passwords.

    :param chars:

        Optionally specify custom string of characters to use when randomly
        generating a password. This option cannot be combined with **charset**.

    :param charset:

        The predefined character set to draw from (if not specified by **chars**).
        There are currently four presets available:

        * ``"ascii_62"`` (the default) -- all digits and ascii upper & lowercase letters.
          Provides ~5.95 entropy per character.

        * ``"ascii_50"`` -- subset which excludes visually similar characters
          (``1IiLl0Oo5S8B``). Provides ~5.64 entropy per character.

        * ``"ascii_72"`` -- all digits and ascii upper & lowercase letters,
          as well as some punctuation. Provides ~6.17 entropy per character.

        * ``"hex"`` -- Lower case hexadecimal.  Providers 4 bits of entropy per character.

    :returns:
        :class:`!unicode` string containing randomly generated password;
        or list of 1+ passwords if :samp:`returns={int}` is specified.
    )rt   rz   rn   )r    ©rz   rt   rŠ   r{   Úgens        r*   r   r   ¨  s-   € õL Ð
?˜v¨wÐ
?Ð
?¸$Ð
?Ð
?€CØˆ3ˆw‰<Œ<Ðr,   c                 óò   — t          | d¦  «        5 }d„ |D ¦   «         }t          d„ |D ¦   «         ¦  «        }ddd¦  «         n# 1 swxY w Y   t                               dt	          |¦  «        | ¦  «         |S )a2  
    load wordset from compressed datafile within package data.
    file should be utf-8 encoded

    :param asset_path:
        string containing  absolute path to wordset file,
        or "python.module:relative/file/path".

    :returns:
        tuple of words, as loaded from specified words file.
    zutf-8c              3   ó>   K  — | ]}|                      ¦   «         V — Œd S rU   )ÚstriprX   s     r*   r3   z _load_wordset.<locals>.<genexpr>  s*   è è € Ð+Ð+ ˆt�zŠz‰|Œ|Ð+Ð+Ð+Ð+Ð+Ð+r,   c              3   ó   K  — | ]}|¯|V — Œ	d S rU   rn   rX   s     r*   r3   z _load_wordset.<locals>.<genexpr>  s'   è è € Ð3Ð3˜t¨dÐ3�dÐ3Ð3Ð3Ð3Ð3Ð3r,   Nz!loaded %d-element wordset from %r)rC   Útupler
   Údebugr4   )Ú
asset_pathÚfhrª   Úwordss       r*   Ú_load_wordsetr´   õ  s¹   € õ 
˜* gÑ	.Ô	.ð 4°"Ø+Ð+¨Ð+Ñ+Ô+ˆÝÐ3Ð3 sÐ3Ñ3Ô3Ñ3Ô3ˆð4ð 4ð 4ñ 4ô 4ð 4ð 4ð 4ð 4ð 4ð 4øøøð 4ð 4ð 4ð 4õ$ ‡I‚IÐ1µ3°u±:´:¸zÑJÔJÐJØ€Ls   ‘&AÁAÁ
Ac                   ój   ‡ — e Zd ZdZdZdZˆ fd„Zd„ Zd„ Zd„ Z	d„ Z
ed„ ¦   «         Zd	„ Zd
„ Zd„ Zˆ xZS )ÚWordsetDictz¢
    Special mapping used to store dictionary of wordsets.
    Different from a regular dict in that some wordsets
    may be lazy-loaded from an asset path.
    Nc                 ód   •— i | _         i | _         t          t          | ¦  «        j        |i |¤Ž d S rU   )ÚpathsÚ_loadedrw   r¶   rx   )ry   Úargsr{   r}   s      €r*   rx   zWordsetDict.__init__%  s9   ø€ ØˆŒ
ØˆŒØ)��k˜4Ñ Ô Ô)¨4Ð8°4Ð8Ð8Ð8Ð8Ð8r,   c                 óŽ   — 	 | j         |         S # t          $ r Y nw xY w| j        |         }t          |¦  «        x}| j         |<   |S rU   )r¹   ÚKeyErrorr¸   r´   )ry   ÚkeyrE   r2   s       r*   Ú__getitem__zWordsetDict.__getitem__*  s]   € ð	Ø”< Ô$Ð$øÝð 	ð 	ð 	ØˆDð	øøøàŒz˜#ŒˆÝ$1°$Ñ$7Ô$7Ð7ˆ�”˜SÑ!Øˆs   ‚ �
›c                 ó   — || j         |<   dS )z;
        set asset path to lazy-load wordset from.
        N)r¸   )ry   r½   rE   s      r*   Úset_pathzWordsetDict.set_path3  s   € ð ˆŒ
�3‰ˆˆr,   c                 ó   — || j         |<   d S rU   )r¹   )ry   r½   r2   s      r*   Ú__setitem__zWordsetDict.__setitem__9  s   € Ø!ˆŒ�SÑÐÐr,   c                 óh   — || v r%| j         |= | j                             |d ¦  «         d S | j        |= d S rU   )r¹   r¸   Úpop©ry   r½   s     r*   Ú__delitem__zWordsetDict.__delitem__<  s>   € Ø�$ˆ;ˆ;Ø”˜SÐ!ØŒJ�NŠN˜3 Ñ%Ô%Ð%Ð%Ð%à”
˜3���r,   c                 ób   — t          | j        ¦  «        }|                     | j        ¦  «         |S rU   )r^   r¹   Úupdater¸   )ry   rv   s     r*   Ú_keysetzWordsetDict._keysetC  s*   € å�4”<Ñ Ô ˆØ�Š�D”JÑÔÐØˆr,   c                 ó*   — t          | j        ¦  «        S rU   )r‹   rÉ   r   s    r*   r�   zWordsetDict.__iter__I  s   € Ý�D”LÑ!Ô!Ð!r,   c                 ó*   — t          | j        ¦  «        S rU   )r4   rÉ   r   s    r*   Ú__len__zWordsetDict.__len__L  s   € Ý�4”<Ñ Ô Ð r,   c                 ó&   — || j         v p|| j        v S rU   )r¹   r¸   rÅ   s     r*   Ú__contains__zWordsetDict.__contains__P  s   € Ø�d”lÐ"Ð7 c¨T¬ZÐ&7Ð7r,   )r’   r“   r”   r•   r¸   r¹   rx   r¾   rÀ   rÂ   rÆ   ÚpropertyrÉ   r�   rÌ   rÎ   r–   r—   s   @r*   r¶   r¶     sÔ   ø€ € € € € ðð ð €Eð €Gð9ð 9ð 9ð 9ð 9ð
ð ð ðð ð ð"ð "ð "ð ð  ð  ð ðð ñ „Xðð
"ð "ð "ð!ð !ð !ð8ð 8ð 8ð 8ð 8ð 8ð 8r,   r¶   z%eff_long eff_short eff_prefixed bip39zpasslib:_data/wordsets/%s.txtc                   óL   ‡ — e Zd ZdZdZdZdZdˆ fd„	Zed„ ¦   «         Z	d„ Z
ˆ xZS )	ÚPhraseGeneratoraÌ  class which generates passphrases by randomly choosing
    from a list of unique words.

    :param wordset:
        wordset to draw from.
    :param preset:
        name of preset wordlist to use instead of ``wordset``.
    :param spaces:
        whether to insert spaces between words in output (defaults to ``True``).
    :param \*\*kwds:
        all other keywords passed to the :class:`SequenceGenerator` parent class.

    .. autoattribute:: wordset
    Úeff_longNú c                 ól  •— |�|�t          d¦  «        ‚n|€| j        }|sJ ‚t          |         }|| _        t          |t          ¦  «        st          |¦  «        }t          |d¬¦  «         || _        |€| j        }t          |d¬¦  «        }|| _         t          t          | ¦  «        j        di |¤Ž d S )Nz,`words` and `wordset` are mutually exclusiver³   r£   rN   rn   )r5   Úwordsetr   r\   Ú_sequence_typesr¯   rj   r³   rN   r   rw   rÑ   rx   )ry   rÕ   r³   rN   r{   r}   s        €r*   rx   zPhraseGenerator.__init__~  sØ   ø€ ð ÐØÐ"ÝÐ NÑOÔOÐOð #ð ˆØœ,�Ø���wÝ$ WÔ-ˆEØˆŒõ ˜%¥Ñ1Ô1ð 	!Ý˜%‘L”LˆEÝ�u GÐ,Ñ,Ô,Ð,ØˆŒ
ð ˆ;Ø”(ˆCÝ˜ EÐ*Ñ*Ô*ˆØˆŒð 	.��o˜tÑ$Ô$Ô-Ð5Ð5°Ð5Ð5Ð5Ð5Ð5r,   c                 ó*   — t          | j        ¦  «        S rU   )r4   r³   r   s    r*   ro   zPhraseGenerator.symbol_count   r¦   r,   c                 óx   ‡ — ˆ fd„t          ‰ j        ¦  «        D ¦   «         }‰ j                             |¦  «        S )Nc              3   óV   •K  — | ]#}‰j                              ‰j        ¦  «        V — Œ$d S rU   )r   Úchoicer³   r‡   s     €r*   r3   z+PhraseGenerator.__next__.<locals>.<genexpr>©  s3   øè è € ÐJÐJ°�”—’ ¤Ñ,Ô,ÐJÐJÐJÐJÐJÐJr,   )r   rt   rN   ra   )ry   r³   s   ` r*   rƒ   zPhraseGenerator.__next__¨  s:   ø€ ØJÐJÐJÐJµf¸T¼[Ñ6IÔ6IÐJÑJÔJˆØŒx�}Š}˜UÑ#Ô#Ð#r,   r‘   )r’   r“   r”   r•   rÕ   r³   rN   rx   r   ro   rƒ   r–   r—   s   @r*   rÑ   rÑ   _  sˆ   ø€ € € € € ðð ð& €Gð €Eð €Cð
6ð 6ð 6ð 6ð 6ð 6ðD ðð ñ Ôðð$ð $ð $ð $ð $ð $ð $r,   rÑ   c                 ó6   — t          d| |dœ|¤Ž} ||¦  «        S )am  Generate one or more random password / passphrases.

    This function uses :mod:`random.SystemRandom` to generate
    one or more passwords; it can be configured to generate
    alphanumeric passwords, or full english phrases.
    The complexity of the password can be specified
    by size, or by the desired amount of entropy.

    Usage Example::

        >>> # generate random phrase with 48 bits of entropy
        >>> from passlib import pwd
        >>> pwd.genphrase()
        'gangly robbing salt shove'

        >>> # generate a random phrase with 52 bits of entropy
        >>> # using a particular wordset
        >>> pwd.genword(entropy=52, wordset="bip39")
        'wheat dilemma reward rescue diary'

    :param entropy:
        Strength of resulting password, measured in 'guessing entropy' bits.
        An appropriate **length** value will be calculated
        based on the requested entropy amount, and the size of the word set.

        This can be a positive integer, or one of the following preset
        strings: ``"weak"`` (24), ``"fair"`` (36),
        ``"strong"`` (48), and ``"secure"`` (56).

        If neither this or **length** is specified, **entropy** will default
        to ``"strong"`` (48).

    :param length:
        Length of resulting password, measured in words.
        If omitted, the size is auto-calculated based on the **entropy** parameter.

        If both **entropy** and **length** are specified,
        the stronger value will be used.

    :param returns:
        Controls what this function returns:

        * If ``None`` (the default), this function will generate a single password.
        * If an integer, this function will return a list containing that many passwords.
        * If the ``iter`` builtin, will return an iterator that yields passwords.

    :param words:

        Optionally specifies a list/set of words to use when randomly generating a passphrase.
        This option cannot be combined with **wordset**.

    :param wordset:

        The predefined word set to draw from (if not specified by **words**).
        There are currently four presets available:

        ``"eff_long"`` (the default)

            Wordset containing 7776 english words of ~7 letters.
            Constructed by the EFF, it offers ~12.9 bits of entropy per word.

            This wordset (and the other ``"eff_"`` wordsets)
            were `created by the EFF <https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases>`_
            to aid in generating passwords.  See their announcement page
            for more details about the design & properties of these wordsets.

        ``"eff_short"``

            Wordset containing 1296 english words of ~4.5 letters.
            Constructed by the EFF, it offers ~10.3 bits of entropy per word.

        ``"eff_prefixed"``

            Wordset containing 1296 english words of ~8 letters,
            selected so that they each have a unique 3-character prefix.
            Constructed by the EFF, it offers ~10.3 bits of entropy per word.

        ``"bip39"``

            Wordset of 2048 english words of ~5 letters,
            selected so that they each have a unique 4-character prefix.
            Published as part of Bitcoin's `BIP 39 <https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt>`_,
            this wordset has exactly 11 bits of entropy per word.

            This list offers words that are typically shorter than ``"eff_long"``
            (at the cost of slightly less entropy); and much shorter than
            ``"eff_prefixed"`` (at the cost of a longer unique prefix).

    :param sep:
        Optional separator to use when joining words.
        Defaults to ``" "`` (a space), but can be an empty string, a hyphen, etc.

    :returns:
        :class:`!unicode` string containing randomly generated passphrase;
        or list of 1+ passphrases if :samp:`returns={int}` is specified.
    )rz   rt   rn   )rÑ   r©   s        r*   r   r   ±  s-   € õB Ð
A '°&Ð
AÐ
A¸DÐ
AÐ
A€CØˆ3ˆw‰<Œ<Ðr,   rU   )r9   r‘   )=r•   Ú
__future__r   r   r   r   rA   Úcollectionsr   Úcollections.abcr   ÚImportErrorÚmathr	   r
   r0   ÚloggingÚ	getLoggerr’   rJ   rD   Úpasslibr   Úpasslib.utils.compatr   r   r   r   Úpasslib.utilsr   r   r   Úpasslib.utils.decorr   Ú__all__Údictrq   r+   r=   rC   Úlistr¯   rÖ   r^   Ú	frozensetr]   r[   rj   ru   rl   r   r    r   r´   r¶   r   ÚsplitÚnamerÀ   rÑ   r   rn   r,   r*   ú<module>rí      s†  ðØ 0Ð 0ð SÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ Rà €€€Ø #Ð #Ð #Ð #Ð #Ð #ð+Ø.Ð.Ð.Ð.Ð.Ð.Ð.øØð +ð +ð +à*Ð*Ð*Ð*Ð*Ð*Ð*Ð*ð+øøøð #Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ø €€€Ð'�gÔ'¨Ñ1Ô1�Ø Ð Ð Ð Ø 	€	€	€	ð Ð Ð Ð Ð Ð Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1ðð ð €ð �$àð 
ð 
ð ð ðñ ô €ð*"ð "ð "ð!Rð !Rð !RðX;ð ;ð ;ð ;ð. ˜�-€Ø�9Ð€
ð �s‘u”uÐ ð)(ð )(ð )(ð )(ð\I#ð I#ð I#ð I#ð I#˜ñ I#ô I#ð I#ðh �4àWð Nð Bð 	ðñ ô Ð ð$E=ð E=ð E=ð E=ð E=Ð%ñ E=ô E=ð E=ðXGð Gð Gð GðZ ð  ð  ðF98ð 98ð 98ð 98ð 98�.ñ 98ô 98ð 98ð| �;‘=”=Ð ð 4×9Ò9Ñ;Ô;ð Lð L€DØ×Ò˜dÐ$CÀdÑ$JÑKÔKÐKÐKð
K$ð K$ð K$ð K$ð K$Ð'ñ K$ô K$ð K$ðdbð bð bð bð bð bs   š! ¡/®/