
    P1ez
                     L   d dl Z d dlmZmZ d dlmZmZ d dlZd dlZd dlm	Z	 dZ
dZ e	j                    Zej        Zej        Zej        Zddeeef         ded	efd
Zddeeef         ded	efdZ	 d dlmZ  edgd          Zded	efdZdeded	efdZd Zd Zd Z d Z!dS )    N)datetime	timedelta)UnionAny)base_config   i`'  subjectexpires_deltareturnc                     |t          j                    |z   }n)t          j                    t          t                    z   }|t	          |           d}t          j        |t          t                    }|S N)minutes)expsub)	r   utcnowr   ACCESS_TOKEN_EXPIRE_MINUTESstrjwtencodeJWT_SECRET_KEY	ALGORITHMr	   r
   	to_encodeencoded_jwts       C/Users/daniilossinkin/PycharmProjects/ShopsBackend/src/utils/jwt.pycreate_access_tokenr      sf      ))M9 ))I>Y,Z,Z,ZZ%c'll;;I*Y	BBK    c                     |t          j                    |z   }n)t          j                    t          t                    z   }|t	          |           d}t          j        |t          t                    }|S r   )	r   r   r   REFRESH_TOKEN_EXPIRE_MINUTESr   r   r   JWT_REFRESH_SECRET_KEYr   r   s       r   create_refresh_tokenr!      sg      ))M9 ))I>Z,[,[,[[%c'll;;I*Y(>	JJKr   )CryptContextbcryptauto)schemes
deprecatedpasswordc                 6    t                               |           S N)password_contexthash)r'   s    r   get_hashed_passwordr,   .   s      ***r   hashed_passc                 (    t          |           |k    S r)   )hash_password)r'   r-   s     r   verify_passwordr0   2   s    ""k11r   c                 :    t          t          |                     S r)   )sha256_hash	sha1_hashinput_strings    r   r/   r/   6   s    y..///r   c                 D    t          | t          j                              S )z
    Computes the SHA-1 hash of the given input string and returns it as a hexadecimal string.

    :param input_string: String to hash.
    :return: SHA-1 hash of input_string as a hexadecimal string.
    )__hashhashlibsha1r4   s    r   r3   r3   :   s     ,///r   c                 D    t          | t          j                              S )z
    Computes the SHA-256 hash of the given input string and returns it as a hexadecimal string.

    :param input_string: String to hash.
    :return: SHA-256 hash of input_string as a hexadecimal string.
    )r7   r8   sha256r4   s    r   r2   r2   D   s     , 0 0111r   c                     |                      d          }|                    |           |                                }|S )Nzutf-8)r   update	hexdigest)r5   hash_objinput_byteshex_digs       r   r7   r7   N   s=    %%g..KOOK     ""GNr   r)   )"r8   r   r   typingr   r   r   os
src.configr   r   r   get_settingssettingsjwt_algorithmr   	jwt_tokenr   jwt_refresh_tokenr    r   intr   r!   passlib.contextr"   r*   r,   boolr0   r/   r3   r2   r7    r   r   <module>rN      s    ( ( ( ( ( ( ( (         



 				 " " " " " "  * #;#%%"	#!3  sCx  PS     %S/ # QT     ) ( ( ( ( (<
vFFF +# +# + + + +2c 2 2 2 2 2 20 0 00 0 02 2 2    r   