o
    >e                     @   s   d dl mZ d dlmZ dZdZG dd deZG dd deZd	ed
edefddZ	d	ed
edefddZ
d	ed
edefddZd	ed
edefddZd	eded
edefddZd	eded
edefddZdS )    )	CryptBase)DependencyErrorz/cryptography>=3.1 is required for AES algorithm)local_crypt_fallbackz0.0.0c                   @   B   e Zd ZdeddfddZdedefddZdedefd	d
ZdS )CryptRC4keyreturnNc                 C   sh   t td| _d}tdD ]$}|| j|  ||t|   d }| j| | j| | j|< | j|< qd S )N   r   )	bytearrayrangeslen)selfr   ji r   a/var/www/html/humari/django-venv/lib/python3.10/site-packages/pypdf/_crypt_providers/_fallback.py__init__&   s   "$zCryptRC4.__init__datac                 C   s   t | j}dd tt|D }d\}}tt|D ]1}|d d }|||  d }|| || ||< ||< ||| ||  d  }|| |A ||< qtt |S )Nc                 S   s   g | ]}d qS )r   r   ).0_r   r   r   
<listcomp>/   s    z$CryptRC4.encrypt.<locals>.<listcomp>)r   r      r	   )r
   r   r   r   bytes)r   r   r   outr   r   kxr   r   r   encrypt-   s   
zCryptRC4.encryptc                 C   s
   |  |S N)r   r   r   r   r   r   decrypt9   s   
zCryptRC4.decrypt__name__
__module____qualname__r   r   r   r    r   r   r   r   r   %   s    r   c                   @   r   )CryptAESr   r   Nc                 C   s   d S r   r   )r   r   r   r   r   r   >   s   zCryptAES.__init__r   c                 C      t tr   r   _DEPENDENCY_ERROR_STRr   r   r   r   r   A      zCryptAES.encryptc                 C   r&   r   r'   r   r   r   r   r    D   r)   zCryptAES.decryptr!   r   r   r   r   r%   =   s    r%   r   r   r   c                 C      t | |S r   )r   r   r   r   r   r   r   rc4_encryptH      r,   c                 C   r*   r   )r   r    r+   r   r   r   rc4_decryptL   r-   r.   c                 C   r&   r   r'   r+   r   r   r   aes_ecb_encryptP   r)   r/   c                 C   r&   r   r'   r+   r   r   r   aes_ecb_decryptT   r)   r0   ivc                 C   r&   r   r'   r   r1   r   r   r   r   aes_cbc_encryptX   r)   r3   c                 C   r&   r   r'   r2   r   r   r   aes_cbc_decrypt\   r)   r4   N)pypdf._crypt_providers._baser   pypdf.errorsr   r(   crypt_providerr   r%   r   r,   r.   r/   r0   r3   r4   r   r   r   r   <module>   s   