File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/mod_random.cpython-310.pyc
Back
o ;j� � @ s� d Z ddlZddlZddlZddlZddlmZ dZdd� Z ddd �Z ddd�Z d dd�Zd!dd�Z d"dd�Zd#dd�Zd$dd�Zd$dd�ZdS )%zr Provides access to randomness generators. ========================================= .. versionadded:: 2014.7.0 � N)�SaltInvocationError�randomc C s t S �N)�__virtualname__� r r �K/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/mod_random.py�__virtual__ s r �sha512c C � t jjj| |d�S )aM .. versionadded:: 2014.7.0 Encodes a value with the specified encoder. value The value to be hashed. algorithm : sha512 The algorithm to use. May be any valid algorithm supported by hashlib. CLI Example: .. code-block:: bash salt '*' random.hash 'I am a string' md5 )� algorithm)�salt�utils�data�hash)�valuer r r r r � r �base64c C s� t | t�r | �t�} |dkr'z t�| �}|�t�}W |S ty& td��w z| �|�}W |S t y: td�� t yD td��w )a .. versionadded:: 2014.7.0 value The value to be encoded. encoder : base64 The encoder to use on the subsequent string. CLI Example: .. code-block:: bash salt '*' random.str_encode 'I am a new string' base64 r z#Value must be an encode-able stringz You must specify a valid encoder)� isinstance�str�encodeZ__salt_system_encoding__r � b64encode�decode� TypeErrorr �LookupError�AttributeError)r �encoder�outr r r � str_encode. s$ ����r � TFc C s t jjj| |||||||d�S )a .. versionadded:: 2014.7.0 .. versionchanged:: 3004 Changed the default character set used to include symbols and implemented arguments to control the used character set. Returns a random string of the specified length. length : 20 Any valid number of bytes. chars : None .. versionadded:: 3004 String with any character that should be used to generate random string. This argument supersedes all other character controlling arguments. lowercase : True .. versionadded:: 3004 Use lowercase letters in generated random string. (see :py:data:`string.ascii_lowercase`) This argument is superseded by chars. uppercase : True .. versionadded:: 3004 Use uppercase letters in generated random string. (see :py:data:`string.ascii_uppercase`) This argument is superseded by chars. digits : True .. versionadded:: 3004 Use digits in generated random string. (see :py:data:`string.digits`) This argument is superseded by chars. printable : False .. versionadded:: 3004 Use printable characters in generated random string and includes lowercase, uppercase, digits, punctuation and whitespace. (see :py:data:`string.printable`) It is disabled by default as includes whitespace characters which some systems do not handle well in passwords. This argument also supersedes all other classes because it includes them. This argument is superseded by chars. punctuation : True .. versionadded:: 3004 Use punctuation characters in generated random string. (see :py:data:`string.punctuation`) This argument is superseded by chars. whitespace : False .. versionadded:: 3004 Use whitespace characters in generated random string. (see :py:data:`string.whitespace`) It is disabled by default as some systems do not handle whitespace characters in passwords well. This argument is superseded by chars. CLI Example: .. code-block:: bash salt '*' random.get_str 128 salt '*' random.get_str 128 chars='abc123.!()' salt '*' random.get_str 128 lowercase=False whitespace=True ��length�charsZ lowercaseZ uppercase�digits�punctuation� whitespace� printable)r r �pycryptoZsecure_passwordr r r r �get_strP s \�r'