ó
    _š‘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   ó    ÚWC:\Users\psant\Downloads\Noiseback\school\venv\Lib\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ô
 �8Š8�Cœ[¨Ó/¸6ÑBÐBøô ó ÜØDÀyÑ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º-°Q”7—>’> -×0Ð0º-ùs   ƒ#&)ÚjoinÚrange)Úlengthr-   s    `r   Úget_random_stringr3   3   s   ø€ ð �7‰7Ô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   € à�~Ü—‘ˆØ�M�T€EÜ˜8Ó$€HÜ�tÓ€DÜ×Ò™v›xŸ}™}¨h¸jÓ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   