
    hf
                         S r SSKrSSKrSSKrSSKJr  SSKJr   " S S\5      r	SSS.S	 jjr
S
r\4S jrS rSS jrg)z3
Django's standard crypto functions and utilities.
    N)settings)force_bytesc                       \ rS rSrSrSrg)InvalidAlgorithm   z&Algorithm is not supported by hashlib. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       E/var/www/html/env/lib/python3.13/site-packages/django/utils/crypto.pyr   r      s    0r   r   sha1)	algorithmc                &   Uc  [         R                  n[        U 5      n [        U5      n [        [        U5      nU" X-   5      R                  5       n[        R                  " U[        U5      US9$ ! [
         a  n[        SU-  5      UeSnAff = f)a  
Return the HMAC of 'value', using a key generated from key_salt and a
secret (which defaults to settings.SECRET_KEY). Default algorithm is SHA1,
but any algorithm name supported by hashlib can be passed.

A different key_salt should be passed in for every application of HMAC.
Nz6%r is not an algorithm accepted by the hashlib module.)msg	digestmod)
r   
SECRET_KEYr   getattrhashlibAttributeErrorr   digesthmacnew)key_saltvaluesecretr   hasherekeys          r   salted_hmacr#      s     ~$$8$H F), "
#
*
*
,C
 88C[/6BB  DyP
	s   A2 2
B<BB>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789c                 L   ^ SR                  U4S j[        U 5       5       5      $ )a+  
Return a securely generated random string.

The bit length of the returned value can be calculated with the formula:
    log_2(len(allowed_chars)^length)

For example, with default `allowed_chars` (26+26+10), this gives:
  * length: 12, bit length =~ 71 bits
  * length: 22, bit length =~ 131 bits
 c              3   P   >#    U  H  n[         R                  " T5      v   M     g 7fN)secretschoice).0iallowed_charss     r   	<genexpr>$get_random_string.<locals>.<genexpr>>   s     H-Q7>>-00-s   #&)joinrange)lengthr-   s    `r   get_random_stringr3   3   s     77H%-HHHr   c                 T    [         R                  " [        U 5      [        U5      5      $ )z:Return True if the two strings are equal, False otherwise.)r)   compare_digestr   )val1val2s     r   constant_time_comparer8   A   s    !!+d"3[5FGGr   c                     Uc  [         R                  nU=(       d    Sn[        U 5      n [        U5      n[         R                  " U" 5       R                  XX#5      $ )z)Return the hash of password using pbkdf2.N)r   sha256r   pbkdf2_hmacname)passwordsalt
iterationsdklenr   s        r   pbkdf2rA   F   sH    ~MTE8$HtDvx}}hjPPr   r(   )r   N)r   r   r   r)   django.confr   django.utils.encodingr   
ValueErrorr   r#   RANDOM_STRING_CHARSr3   r8   rA   r   r   r   <module>rF      sV         -	z 	C6 C: W  -@ IH
Qr   