403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.9/site-packages/passlib/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/passlib/__pycache__/pwd.cpython-39.opt-1.pyc
a

f�Wcp�@s�dZddlmZmZmZmZddlZddlmZzddl	m
Z
Wney^ddlm
Z
Yn0ddlm
Z
mZddlZe�e�ZddlZddlZddlmZddlmZmZmZmZdd	lmZmZmZdd
l m!Z!gd�Z"e#dd
dddd�Z$dd�Z%dd�Z&d0dd�Z'e(e)fZ*e+e,fZ-e+�Z.d1dd�Z/Gdd�de0�Z1e#dddd d!�Z2Gd"d#�d#e1�Z3d2d$d%�Z4d&d'�Z5Gd(d)�d)e
�Z6e6�Z7d*�8�D]Z9e7�:e9d+e9��q�Gd,d-�d-e1�Z;d3d.d/�Z<dS)4z*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�<)ZunsafeZweakZfair�strongZsecurecCs t|�j}||�|�dd�S)z2return remaining classes in object's MRO after cls�N)�type�__mro__�index)�obj�cls�mro�r$�//usr/lib/python3.9/site-packages/passlib/pwd.py�
_superclasses8s
r&cCs�zt|�}Wnty"d}Yn0tt�}|D]}||d7<q0|dur`|��}t|�}nt|�}|spdSt|d�tdd�|D��|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
    Nrr�css|]}|t|d�VqdS)r'N)�logf)�.0�valuer$r$r%�	<genexpr>_�z"_self_info_rate.<locals>.<genexpr>)�len�	TypeErrorr�int�values�sumr
r()�source�sizeZcounts�charr0r$r$r%�_self_info_rate>s

r5cCsZ|rt�|�t|��Stj�|�r,t|d�S|�d�\}}}|sNtd|f��t	�
||�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�:zKasset path must be absolute file path or use 'pkg.name:sub/path' format: %r)�codecs�	getreader�_open_asset_path�os�path�isabs�open�	partition�
ValueError�
pkg_resourcesZresource_stream)r<�encoding�package�sepZsubpathr$r$r%r:js
�r:r2c	Cst}d}z||vrWdSWnty0d}Yn0t|t�sPtt|��t|�krz|rvz|�|�WntytYn0dSt�}t�}|D]}||vr�|n|�|�q�t|�}d}t|�|kr�d}d�dd�|d|�D��}t|�|kr�|d	t|�|7}t	d
||f��dS)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���, css|]}tt|��VqdS�N)�repr�str�r)Zwordr$r$r%r+�r,z!_ensure_unique.<locals>.<genexpr>Nz, ... plus %d othersz*`%s` cannot contain duplicate elements: %s)
�_ensure_unique_cacher.�
isinstance�
_set_typesr-�set�add�sorted�joinr@)	r2�param�cacheZhashable�seenZdups�elemZtruncZdup_reprr$r$r%�_ensure_unique�s8

�rWcspeZdZdZdZdZeZdZd�fdd�	Ze	dd��Z
e	dd	��Zd
d�Zddd
�Z
dd�Zerhdd�Z�ZS)�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.
    Nrcs�|dus|dur`|dur|j}t�||�}|dkr:td��tt||j��}|dus\||kr`|}||_|dkrvtd��||_|dur�||_|r�t	|t
�tfkr�tdd�
|�����tt
|�jfi|��dS)Nrz!`entropy` must be positive numberrz!`length` must be positive integerzUnexpected keyword(s): %srG)�requested_entropy�entropy_aliases�getr@r/r�entropy_per_symbol�lengthrr&rX�objectr.rR�keys�super�__init__)�self�entropyr]r�kwdsZ
min_length��	__class__r$r%ra�s$zSequenceGenerator.__init__cCst|jd�S)zZ
        Average entropy per symbol (assuming all symbols have equal probability)
        r')r(�symbol_count�rbr$r$r%r\sz$SequenceGenerator.entropy_per_symbolcCs|j|jS)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`.
        )r]r\rhr$r$r%rcs	zSequenceGenerator.entropycCstd��dS)z;main generation function, should create one password/phrasezimplement in subclassN)�NotImplementedErrorrhr$r$r%�__next__)szSequenceGenerator.__next__csN|durt��St|t�r0�fdd�t|�D�S|tur<�St�|dd��dS)zN
        frontend used by genword() / genphrase() to create passwords
        Ncsg|]}t���qSr$)�next�r)�_rhr$r%�
<listcomp>4r,z.SequenceGenerator.__call__.<locals>.<listcomp>z<None>, int, or <iter>�returns)rkrMrr�iterr
ZExpectedTypeError)rbror$rhr%�__call__-s
zSequenceGenerator.__call__cCs|SrHr$rhr$r$r%�__iter__:szSequenceGenerator.__iter__cCs|��SrH)rjrhr$r$r%rk>szSequenceGenerator.next)NNN)N)�__name__�
__module__�__qualname__�__doc__r]rYrrgrarr\rcrjrqrrrrk�
__classcell__r$r$rer%rX�s,#




rXzH0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*?/Z>0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZZ2234679abcdefghjkmnpqrstuvwxyzACDEFGHJKMNPQRTUVWXYZZ0123456789abcdef)Zascii_72�ascii_62Zascii_50�hexcs>eZdZdZdZdZd
�fdd�	Zedd��Zdd	�Z	�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
    rxNcsb|r|r$td��n|s|j}t|}||_t|dd�}t|dd�||_tt|�jfi|��dS)Nz,`chars` and `charset` are mutually exclusive�chars�rS)	r.�charsetrrrWr{r`rzra)rbr{r}rdrer$r%ra~s
zWordGenerator.__init__cCs
t|j�SrH)r-r{rhr$r$r%rg�szWordGenerator.symbol_countcCst|j|j|j�SrH)rrr{r]rhr$r$r%rj�szWordGenerator.__next__)NN)rsrtrurvr}r{rarrgrjrwr$r$rer%rz\s
rzcKstf||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.
    )r]rc)rz�rcr]rord�genr$r$r%r�sFrcCs`t|d��0}dd�|D�}tdd�|D��}Wd�n1s@0Yt�dt|�|�|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.
    zutf-8css|]}|��VqdSrH)�striprKr$r$r%r+r,z _load_wordset.<locals>.<genexpr>css|]}|r|VqdSrHr$rKr$r$r%r+r,Nz!loaded %d-element wordset from %r)r:�tupler	�debugr-)Z
asset_pathZfhr�wordsr$r$r%�
_load_wordset�s

0r�csleZdZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Z	dd�Z
ed
d��Zdd�Z
dd�Zdd�Z�ZS)�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.
    Ncs&i|_i|_tt|�j|i|��dSrH)�paths�_loadedr`r�ra)rb�argsrdrer$r%ra%szWordsetDict.__init__cCs@z|j|WStyYn0|j|}t|�}|j|<|SrH)r��KeyErrorr�r�)rb�keyr<r*r$r$r%�__getitem__*s
zWordsetDict.__getitem__cCs||j|<dS)z;
        set asset path to lazy-load wordset from.
        N)r�)rbr�r<r$r$r%�set_path3szWordsetDict.set_pathcCs||j|<dSrH)r�)rbr�r*r$r$r%�__setitem__9szWordsetDict.__setitem__cCs,||vr |j|=|j�|d�n|j|=dSrH)r�r��pop�rbr�r$r$r%�__delitem__<szWordsetDict.__delitem__cCst|j�}|�|j�|SrH)rOr��updater�)rbr_r$r$r%�_keysetCs
zWordsetDict._keysetcCs
t|j�SrH)rpr�rhr$r$r%rrIszWordsetDict.__iter__cCs
t|j�SrH)r-r�rhr$r$r%�__len__LszWordsetDict.__len__cCs||jvp||jvSrH)r�r�r�r$r$r%�__contains__PszWordsetDict.__contains__)rsrtrurvr�r�rar�r�r�r��propertyr�rrr�r�rwr$r$rer%r�s	
r�z%eff_long eff_short eff_prefixed bip39zpasslib:_data/wordsets/%s.txtcsBeZdZdZdZdZdZd�fdd�	Zedd��Z	d	d
�Z
�ZS)�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
    Zeff_longN� cs�|dur|dur0td��n|dur(|j}t|}||_t|t�sHt|�}t|dd�||_|durh|j}t	|dd�}||_t
t|�jfi|��dS)Nz,`words` and `wordset` are mutually exclusiver�r|rD)
r.�wordsetrrM�_sequence_typesr�rWr�rDrr`r�ra)rbr�r�rDrdrer$r%ra~s 

zPhraseGenerator.__init__cCs
t|j�SrH)r-r�rhr$r$r%rg�szPhraseGenerator.symbol_countcs$�fdd�t�j�D�}�j�|�S)Nc3s|]}�j��j�VqdSrH)r�choicer�rlrhr$r%r+�r,z+PhraseGenerator.__next__.<locals>.<genexpr>)rr]rDrR)rbr�r$rhr%rj�szPhraseGenerator.__next__)NNN)rsrtrurvr�r�rDrarrgrjrwr$r$rer%r�_s"
r�cKstf||d�|��}||�S)amGenerate 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.
    )rcr])r�r~r$r$r%r�sar)N)r2)NNN)NNN)=rvZ
__future__rrrrr8�collectionsr�collections.abcr�ImportErrorZmathrr	r(ZloggingZ	getLoggerrsrAr;Zpasslibr
Zpasslib.utils.compatrrr
rZ
passlib.utilsrrrZpasslib.utils.decorr�__all__�dictrZr&r5r:�listr�r�rO�	frozensetrNrLrWr^rXrrzrr�r�r�split�namer�r�rr$r$r$r%�<module>s^
�,

.�L
M#>R

Youez - 2016 - github.com/yon3zu
LinuXploit