
    Ng                        d Z ddlmZ ddlmZmZmZmZmZ erddl	m
Z
  G d de          Z e            Z G d d          Z G d	 d
e          ZdS )zFor managing PDF encryption.    )annotations)TYPE_CHECKINGAnyLiteral
NamedTuplecast)EncryptionMethodc                      e Zd ZU dZdZded<   	 dZded<   	 dZded<   	 dZded<   	 dZ	ded	<   	 dZ
ded
<   	 dZded<   	 dZded<   dS )Permissionsan  Stores the user-level permissions for an encrypted PDF.

    A compliant PDF reader/writer should enforce these restrictions on people
    who have the user password and not the owner password. In practice, either
    password is sufficient to decrypt all document contents. A person who has
    the owner password should be allowed to modify the document in any way.
    pikepdf does not enforce the restrictions in any way; it is up to application
    developers to enforce them as they see fit.

    Unencrypted PDFs implicitly have all permissions allowed. Permissions can
    only be changed when a PDF is saved.
    Tboolaccessibilityextractmodify_annotationFmodify_assemblymodify_formmodify_otherprint_lowresprint_highresN)__name__
__module____qualname____doc__r   __annotations__r   r   r   r   r   r   r        U/var/www/html/ai-engine/env/lib/python3.11/site-packages/pikepdf/models/encryption.pyr   r      s           M G%"""""'!O!!!!.K#L(L9M::r   r   c                      e Zd ZdZddZedd            Zedd            Zedd	            Zedd            Z	edd            Z
edd            Zedd            Zedd            Zedd            Zd ZdS )EncryptionInfoa  Reports encryption information for an encrypted PDF.

    This information may not be changed, except when a PDF is saved.
    This object is not used to specify the encryption settings to save
    a PDF, due to non-overlapping information requirements.
    encdictdict[str, Any]c                    || _         dS )zInitialize EncryptionInfo.

        Generally pikepdf will initialize and return it.

        Args:
            encdict: Python dictionary containing encryption settings.
        N)_encdict)selfr   s     r   __init__zEncryptionInfo.__init__G   s      r   returnintc                6    t          | j        d                   S )z(Revision number of the security handler.Rr&   r"   r#   s    r   r(   zEncryptionInfo.RQ        4=%&&&r   c                6    t          | j        d                   S )z"Version of PDF password algorithm.Vr)   r*   s    r   r-   zEncryptionInfo.VV   r+   r   c                6    t          | j        d                   S )zPReturn encoded permission bits.

        See :meth:`Pdf.allow` instead.
        Pr)   r*   s    r   r/   zEncryptionInfo.P[   s     4=%&&&r   r	   c                8    t          d| j        d                   S )z)Encryption method used to encode streams.r	   streamr   r"   r*   s    r   stream_methodzEncryptionInfo.stream_methodc        &h(?@@@r   c                8    t          d| j        d                   S )z)Encryption method used to encode strings.r	   stringr2   r*   s    r   string_methodzEncryptionInfo.string_methodh   r4   r   c                8    t          d| j        d                   S )z0Encryption method used to encode the whole file.r	   filer2   r*   s    r   file_methodzEncryptionInfo.file_methodm   s     &f(=>>>r   bytesc                6    t          | j        d                   S )aH  If possible, return the user password.

        The user password can only be retrieved when a PDF is opened
        with the owner password and when older versions of the
        encryption algorithm are used.

        The password is always returned as ``bytes`` even if it has
        a clear Unicode representation.
        user_passwdr;   r"   r*   s    r   user_passwordzEncryptionInfo.user_passwordr   s     T]=1222r   c                6    t          | j        d                   S )z8Return the RC4 or AES encryption key used for this file.encryption_keyr>   r*   s    r   rA   zEncryptionInfo.encryption_key   s     T]#34555r   c                <    t          | j        d                   dz  S )z|Return the number of bits in the encryption algorithm.

        e.g. if the algorithm is AES-256, this returns 256.
        rA      )lenr"   r*   s    r   bitszEncryptionInfo.bits   s     4=!1233a77r   c                    d| j         j         d| j        d| j        d| j        d| j        d| j        d| j        d| j        d	| j	        d
| j
        dS )N<z	: self.R=z	, self.V=z	, self.P=z self.stream_method=z, self.string_method=z, self.file_method=z, self.user_password=z, self.encryption_key=z, self.bits=>)	__class__r   r(   r-   r/   r3   r7   r:   r?   rA   rE   r*   s    r   __repr__zEncryptionInfo.__repr__   s    5' 5 546 5 5df 5 5 5 5!5 5&*&85 55 5$($65 5 "5 5 (,y5 5 5	
r   N)r   r    )r%   r&   )r%   r	   )r%   r;   )r   r   r   r   r$   propertyr(   r-   r/   r3   r7   r:   r?   rA   rE   rJ   r   r   r   r   r   ?   si                ' ' ' X' ' ' ' X' ' ' ' X' A A A XA A A A XA ? ? ? X? 
3 
3 
3 X
3 6 6 6 X6 8 8 8 X8
 
 
 
 
r   r   c                  r    e Zd ZU dZdZded<   	 dZded<   	 dZded<   	 eZ	d	ed
<   	 dZ
ded<   	 dZded<   dS )
Encryptionz=Specify the encryption settings to apply when a PDF is saved. strowneruser   zLiteral[2, 3, 4, 5, 6]r(   r   allowTr   aesmetadataN)r   r   r   r   rP   r   rQ   r(   DEFAULT_PERMISSIONSrS   rT   rU   r   r   r   rM   rM      s         GGEOOOO6
 DNNNN3
 !"A!!!!
 -E,,,,< C? H< <r   rM   N)r   
__future__r   typingr   r   r   r   r   pikepdf._corer	   r   rV   r   rM   r   r   r   <module>rZ      s   # " " " " " " " @ @ @ @ @ @ @ @ @ @ @ @ @ @ /......+; +; +; +; +;* +; +; +;\ "kmm S
 S
 S
 S
 S
 S
 S
 S
l!< !< !< !< !< !< !< !< !< !<r   