
    &i                     t    S r SSKrSSKr SSKrS\S\4S jrS\S\4S jrS\S\4S jr	g! \ a    Sr N&f = f)	z/Password verification and hashing for usuarios.    Nstoredreturnc                 R    [        U [        5      =(       a    U R                  S5      $ )Nz$2)
isinstancestr
startswith)r   s    LC:\Users\user\Desktop\Projetos_em_andamento\LojaOnline\services\passwords.pypassword_is_bcryptr
      s    fc">v'8'8'>>    plainc                    Ub  U c  g[        U [        5      (       a  U R                  SSS9n [        U 5      (       a>  [        c  g [        R
                  " UR                  S5      U R                  S5      5      $ [        U [        5      (       ac  U R                  S5      (       aM  [        R                  " UR                  S5      5      R                  5       n[        R                  " U SU-   5      $ X:H  $ ! [         a     gf = f)NFutf-8replace)errorssha256$)r   bytesdecoder
   bcryptcheckpwencode	Exceptionr   r   hashlibsha256	hexdigesthmaccompare_digest)r   r   	candidates      r	   verify_passwordr      s    }&%  wy9&!!>	>>%,,w"7w9OPP &#6#4#4Y#?#?NN5<<#89CCE	""69y+@AA?  		s   4C7 7
DDc                    [         c8  [        R                  " U R                  S5      5      R	                  5       nSU-   $ [         R
                  " U R                  S5      [         R                  " 5       5      R                  S5      $ )Nr   r   )r   r   r   r   r   hashpwgensaltr   )r   digests     r	   hash_passwordr#   !   s^    ~W 56@@B6!!==g.0@AHHQQr   )
__doc__r   r   r   ImportErrorr   boolr
   r   r#    r   r	   <module>r(      sh    5  
?s ?t ?3 4 $R R R5  Fs   , 77