HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/pycrypto.cpython-310.pyc
o

�N�g��@svdZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
z.zddlmZ
Wn!eyLzddlm
Z
WneyIddlm
Z
YnwYnwdZWney[dZYnwzddlZdZWn
eefyqdZYnwzddlZdZWney�dZYnwe�e�Z									dd	d
�Zer�dd�ejD�ZniZgd
�Zddd�Zddd�Zddd�Z dS)z7
Use pycrypto to generate random passwords on the fly.
�N)�CommandExecutionError�SaltInvocationError)�
rand_bytes)�get_random_bytesTF�c	

CsD|pd}|r	tj}|s.|r|tj7}|r|tj7}|r |tj7}|r'|tj7}|r.|tj7}z\t|�}d}	t|	�|kr�t	ry|ryd}
t
jj�
�rId}
	z
t
jjjtd�|
d�}Wn	ty`YqIw|	t�t
jjjdt�|��d�|
d�d|�7}	n	|	t���|�7}	t|	�|ks;|	WSty�}zt�d	�tt|���d}~ww)
z%
    Generate a secure password.
    �NzUTF-8T�)�encodingz[^�]z#Failed to generate secure passsword)�string�	printable�ascii_lowercase�ascii_uppercase�digits�punctuation�
whitespace�int�len�
HAS_RANDOM�salt�utils�platformZ
is_windowsZstringutilsZto_strr�UnicodeDecodeError�re�sub�escape�random�SystemRandom�choice�	Exception�log�	exceptionr�str)
�lengthZ
use_random�charsZ	lowercaseZ	uppercaserrrrZpwr	�char�exc�r'�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/pycrypto.py�secure_password+s\




�����
��r)cCsi|]}|j��|�qSr')�name�lower)�.0�mr'r'r(�
<dictcomp>isr.)�sha512�sha256Zblowfish�md5�cryptc	Cs�gd�}tjj|d�}||t�|�d�}|r4d|vr4|�d�\}}t|�d�d�}|�||d��n|�|dd	��|jdi|��S)zG
    Generate a /etc/shadow-compatible hash for a non-local system
    )Zsha512_cryptZsha256_cryptZbcryptZ	md5_cryptZ	des_crypt)�schemes)Zsecret�scheme�$�=���)r�roundsT)rZrelaxedNr')	�passlib�contextZCryptContext�
known_methods�index�splitr�update�hash)	�
crypt_salt�password�	algorithmr3�ctx�kwargsZ	roundsstrZ
split_saltr8r'r'r(�_gen_hash_passlibosrEcCs\|dur	t|}n|dkrdt|j�d|��}z	t�||�}W|Sty-d}Y|Sw)zA
    Generate /etc/shadow hash using the native crypt module
    Nr2r5)�methods�identr2�OSError)r@rArB�retr'r'r(�_gen_hash_crypt�s
��rJcCs�|durt�}|durtrtjdj��ntd}|dkr*|r*t|�dkr*t�	d�tr7|tvr7t
|||d�StrD|tvrDt|||d�St
d�|tt�tt���)z#
    Generate /etc/shadow hash
    Nrr2�z'Hash salt is too long for 'crypt' hash.�r@rArBz�Cannot hash using '{}' hash algorithm. Natively supported algorithms are: {}. If passlib is installed ({}), the supported algorithms are: {}.)r)�	HAS_CRYPTr2rFr*r+r;rr �warningrJ�HAS_PASSLIBrEr�format�listrLr'r'r(�gen_hash�s(
����rR)	rTNTTTTFF)NNN)!�__doc__�loggingrrrZsalt.utils.platformrZsalt.utils.stringutilsZsalt.exceptionsrrZ
M2Crypto.Randrr�ImportErrorZCryptodome.RandomZ
Crypto.Randomrr2rM�PermissionErrorZpasslib.contextr9rO�	getLogger�__name__r r)rFr;rErJrRr'r'r'r(�<module>sj������

�=