o
    wvXj¶  ã                   @   st   d Z ddlmZmZ ddlZddlmZ ddlZddl	m
Z
 ddlmZ ddlmZ dZdd
d„Zeddd„ƒZdS )z1Utilities used by the message signing serializer.é    )Úabsolute_importÚunicode_literalsN)Úcontextmanager)Úhashes)ÚSecurityError)Úreraise)Úget_digest_algorithmÚreraise_errorsÚsha256c                 C   s   | dusJ ‚t t|  ¡ ƒƒ S )z6Convert string to hash object of cryptography library.N)Úgetattrr   Úupper)Údigest© r   úR/var/www/html/myproject/venv/lib/python3.10/site-packages/celery/security/utils.pyr      s   r   ú{0!r}c              
   c   sh   � |du r	t jfn|}zdV  W dS  |y3 } zttt|  |¡ƒt ¡ d ƒ W Y d}~dS d}~ww )z8Context reraising crypto errors as :exc:`SecurityError`.Né   )ÚcryptographyÚ
exceptionsr   r   ÚformatÚsysÚexc_info)ÚmsgÚerrorsÚexcr   r   r   r	      s   €
þ€ÿr	   )r
   )r   N)Ú__doc__Ú
__future__r   r   r   Ú
contextlibr   Úcryptography.exceptionsr   Úcryptography.hazmat.primitivesr   Úcelery.exceptionsr   Úcelery.fiver   Ú__all__r   r	   r   r   r   r   Ú<module>   s   
