Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
htpasswd.cpython-313.pyc37 linesDownload Raw Back to __pycache__
1�

2��j	3��L�SrSSKJr SSKrSSKrSSKJr SSKr"SS5rg)z}4A standalone, minimal htpasswd parser.5 6This implementation currently supports bcrypt and SHA1 passwords. SHA1 is insecure.7�)�annotationsN)�Pathc�<�\rSrSrSSjr\SSj5rS	SjrSrg)8�HtpasswdFile�c��0UlUR5H�nUR5nU(aURS5(aM2SU;a[	SU<35eURSS5up4U(d[	SU<35eURS5nURS5nU(dU(d[	SU<35eX@RU'M� g)	z&9Create a HtpasswdFile from a string.10�#�:zMalformed htpasswd line: ��{SHA})z$2y$z$2b$z$2a$z%Unsupported htpasswd format for user N)�users�11splitlines�strip�12startswith�13ValueError�split)�self�content�line�user�pwhash�is_sha�	is_bcrypts       �^D:\code\apps\devtools\python\user_packages\Python313\site-packages\mitmproxy/utils/htpasswd.py�__init__�HtpasswdFile.__init__s���&(��14��&�&�(�D��:�:�<�D��4�?�?�3�/�/���$�� �#<�T�H�!E�F�F��:�:�c�1�-�L�D�� �#<�T�H�!E�F�F��&�&�w�/�F��)�)�*B�C�I��)� �#H���!Q�R�R�%�J�J�t��)�c�p�URS5nU"U5$![a [SU35Sef=f)z�15Initializes and loads an htpasswd file.16 17Args:18    path: The path to the htpasswd file.19 20Raises:21    OSError: If the file cannot be read.22    ValueError: If the file is malformed.23�utf-8zHtpasswd file not found: N)�	read_text�FileNotFoundError�OSError)�cls�pathrs   r�	from_file�HtpasswdFile.from_file'sJ��	H��n�n�W�-�G��7�|���!�	H��5�d�V�<�=�4�G�	H�s��5c���URRU5nUcgURSS5SnURS5(a`[R24"UR
S55R5n[R"U5RS5nUS	SU:H$[R"UR
S5UR
S55$)25z�26Checks if a username and password combination is valid.27 28Args:29    username: The username to check.30    password: The password to check.31 32Returns:33    True if the password is valid, False otherwise.34NFr35rrrr�ascii�)
r
�getrr�hashlib�sha1�encode�digest�base64�	b64encode�decode�bcrypt�checkpw)r�username�passwordrr.�expecteds      r�check_password�HtpasswdFile.check_password9s���������)���>�����c�1�%�a�(�����W�%�%��\�\�(�/�/�'�":�;�B�B�D�F��'�'��/�6�6�w�?�H��!�"�:��)�)��>�>�(�/�/�'�":�F�M�M�'�<R�S�Sr)r
N)r�str)r$r�returnr)r4r9r5r9r:�bool)	�__name__�36__module__�__qualname__�__firstlineno__r�classmethodr%r7�__static_attributes__�rrrrs!��&�,����"Trr)	�__doc__�37__future__rr/r+�pathlibrr2rrBrr�<module>rFs)���#�
���
�AT�ATr
codekingpro/portable-devtools · Team Ai