
    j                         S r SSKrSSKrSSKrSSKrSSKJr  SSKJr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)RemovedInDjango70Warningdjango_file_prefixes)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
       K/var/www/html/KUNJ/venv/lib/python3.13/site-packages/django/utils/crypto.pyr   r      s    0r   r   )	algorithmc                t   Uc$  [         R                  " S[        [        5       S9  Sn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.

Removed in Django70Warning: The default algorithm will change to SHA256
in Django 7.0, so provide an explicit algorithm to silence the warning.

A different key_salt should be passed in for every application of HMAC.
NzThe default argument for algorithm in salted_hmac() will change from 'sha1' to 'sha256' in Django 7.0. Pass an explicit algorithm to silence this warning.)categoryskip_file_prefixessha1z6%r is not an algorithm accepted by the hashlib module.)msg	digestmod)warningswarnr   r   r   
SECRET_KEYr   getattrhashlibAttributeErrorr   digesthmacnew)key_saltvaluesecretr   hasherekeys          r   salted_hmacr)      s     1 .35	
 	~$$8$H F), "
#
*
*
,C
 88C[/6BB  DyP
	s   B 
B7#B22B7>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>M   s     H-Q7>>-00-s   #&)joinrange)lengthr3   s    `r   get_random_stringr9   B   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_comparer>   P   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   pbkdf2rG   U   sH    ~MTE8$HtDvx}}hjPPr   r.   )r   N)r   r   r!   r/   r   django.confr   django.utils.deprecationr   r   django.utils.encodingr   
ValueErrorr   r)   RANDOM_STRING_CHARSr9   r>   rG   r
   r   r   <module>rM      s]          S -	z 	&C4 &CR W  -@ IH
Qr   