o
    ٭h                  
   @   st   d dl Z zd dlZd dlmZ W n ey' Z zddlmZ ededZ[ww ddlm	Z	m
Z
 G dd	 d	e	ZdS )
    N)PasswordHasher   )HasherNotAvailableargon2   )HasherProtocol
ensure_strc                   @   s   e Zd Zejejejejejej	j
fdedededededej	ddfd	d
Zedejeef defddZdddejeef dejedf defddZdejeef dejeef defddZdejeef defddZdS )Argon2Hasher	time_costmemory_costparallelismhash_lensalt_lentypereturnNc                 C   s   t |||||d|| _dS )ah  

        Args:
            time_cost: Defines the amount of computation realized and
                therefore the execution time, given in number of iterations.
            memory_cost: Defines the memory usage, given in kibibytes.
            parallelism: Defines the number of parallel threads (*changes*
                the resulting hash value).
            hash_len: Length of the hash in bytes.
            salt_len: Length of random salt to be generated for each
                password.
            type: Argon2 type to use.  Only change for interoperability
                with legacy systems.

        zutf-8N)r   _hasher)selfr
   r   r   r   r   r    r   Z/var/www/html/stock_analysis/be/venv/lib/python3.10/site-packages/pwdlib/hashers/argon2.py__init__   s   
zArgon2Hasher.__init__hashc                 C   s   t |dS )Nz
$argon2id$)r   
startswith)clsr   r   r   r   identify+   s   zArgon2Hasher.identifysaltpasswordr   c                C   s   | j j||dS )Nr   )r   r   )r   r   r   r   r   r   r   /   s   zArgon2Hasher.hashc              	   C   s2   z| j ||W S  tjjtjjfy   Y dS w )NF)r   verifyr   
exceptionsVerificationErrorInvalidHashError)r   r   r   r   r   r   r   7   s   
zArgon2Hasher.verifyc                 C   s   | j t|S )N)r   check_needs_rehashr   )r   r   r   r   r   r!   D   s   zArgon2Hasher.check_needs_rehash)__name__
__module____qualname__r   DEFAULT_TIME_COSTDEFAULT_MEMORY_COSTDEFAULT_PARALLELISMDEFAULT_HASH_LENGTHDEFAULT_RANDOM_SALT_LENGTHTypeIDintr   classmethodtypingUnionstrbytesboolr   r   r   r!   r   r   r   r   r	      sP    


 r	   )r.   argon2.exceptionsr   r   ImportErrorer   r   baser   r   r	   r   r   r   r   <module>   s    
