o
    -i                     @   s   d dl mZ d dl mZ d dlZd dlZd dlZd dlZddlmZm	Z	m
Z
mZmZmZmZmZ ddlmZ g dZedZddededefddZdededefddZdededefddZ	d dedededededefddZdeddfddZdS )!    )absolute_import)divisionN   )
__author____copyright__	__email____license____summary__	__title____uri____version__)_bcrypt)r
   r	   r   r   r   r   r   r   gensalthashpwkdfcheckpws   ^\$2y\$      2broundsprefixreturnc                 C   s~   |dvrt d| dk s| dkrt dtd}tjdd}tj||t| d	| d	 d
|  	d d	 tj
| S )N)s   2ar   z%Supported prefixes are b'2a' or b'2b'      zInvalid rounds   char[]      $z%2.2uascii)
ValueErrorosurandomr   ffinewlibencode_base64lenencodestring)r   r   saltoutput r*   ]/home/esfera/Desktop/Rishu/Inhouse_Email/venv/lib/python3.10/site-packages/bcrypt/__init__.pyr   8   s&   

r   passwordr(   c                 C   s   t | ts
t |trtdd| v rtd| d d } |td|}}tjdd}tj	
| ||t|}|dkr?td	|d d
 tj|d
d   S )N&Strings must be encoded before hashing    z"password may not contain NUL bytesH   s   $2b$r      r   zInvalid saltr   )
isinstancestr	TypeErrorr   _normalize_resubr   r!   r"   r#   bcrypt_hashpassr%   r'   )r,   r(   original_salthashedretvalr*   r*   r+   r   M   s    r   hashed_passwordc                 C   sJ   t | ts
t |trtdd| v sd|v rtdt| |}t||S )Nz'Strings must be encoded before checkingr.   z6password and hashed_password may not contain NUL bytes)r1   r2   r3   r   r   hmaccompare_digest)r,   r:   retr*   r*   r+   r   s   s   
r   Fdesired_key_bytesignore_few_roundsc              	   C   s   t | ts
t |trtdt| dkst|dkrtd|dks&|dkr*td|dk r2td|dk rC|sCtjd	|td
d t	j
d|}t	j| t| |t||t||}t|dk t	j
||d d  S )Nr-   r   z#password and salt must not be emptyi   zdesired_key_bytes must be 1-512r   zrounds must be 1 or more2   zrWarning: bcrypt.kdf() called with only {0} round(s). This few is not secure: the parameter is linear, like PBKDF2.   )
stacklevelz	uint8_t[])r1   r2   r3   r%   r   warningswarnformatUserWarningr   r!   r"   r#   bcrypt_pbkdf_bcrypt_assertbuffer)r,   r(   r>   r   r?   keyresr*   r*   r+   r      s*   	r   okc                 C   s   | st dd S )Nzbcrypt assertion failed)SystemError)rL   r*   r*   r+   rH      s   rH   )r   r   )F)
__future__r   r   r;   r   rerC   	__about__r   r   r   r   r	   r
   r   r    r   __all__compiler4   intbytesr   r   boolr   r   rH   r*   r*   r*   r+   <module>   s8   (

&
)