o
    e                     @  s   d Z ddlmZ ddlZddlmZmZmZmZ ej	dkr$ddlm
Z
 nddlm
Z
 er2ddlmZ G dd	 d	eZe ZG d
d dZG dd deZdS )zFor managing PDF encryption.    )annotationsN)TYPE_CHECKINGAny
NamedTuplecast)      )Literal)EncryptionMethodc                   @  s   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 )Permissionsas  
    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    r   r   ID:\Projects\ConvertPro\env\Lib\site-packages\pikepdf/models/encryption.pyr      s$   
 r   c                   @  s   e Zd ZdZdddZeddd	Zedd
dZedddZedddZ	edddZ
edddZed ddZed ddZedd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                 C  s
   || _ dS )z
        Initialize EncryptionInfo.

        Generally pikepdf will initialize and return it.

        Args:
            encdict: Python dictionary containing encryption settings.
        N)_encdict)selfr   r   r   r   __init__H   s   
	zEncryptionInfo.__init__returnintc                 C     t | jd S )z(Revision number of the security handler.Rr#   r   r    r   r   r   r%   S      zEncryptionInfo.Rc                 C  r$   )z"Version of PDF password algorithm.Vr&   r'   r   r   r   r)   X   r(   zEncryptionInfo.Vc                 C  r$   )zPReturn encoded permission bits.

        See :meth:`Pdf.allow` instead.
        Pr&   r'   r   r   r   r*   ]   s   zEncryptionInfo.Pr
   c                 C     t d| jd S )z)Encryption method used to encode streams.r
   streamr   r   r'   r   r   r   stream_methode      zEncryptionInfo.stream_methodc                 C  r+   )z)Encryption method used to encode strings.r
   stringr-   r'   r   r   r   string_methodj   r/   zEncryptionInfo.string_methodc                 C  r+   )z0Encryption method used to encode the whole file.r
   filer-   r'   r   r   r   file_methodo   r/   zEncryptionInfo.file_methodbytesc                 C  r$   )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r4   r   r'   r   r   r   user_passwordt   s   zEncryptionInfo.user_passwordc                 C  r$   )z8Return the RC4 or AES encryption key used for this file.encryption_keyr6   r'   r   r   r   r8      r(   zEncryptionInfo.encryption_keyc                 C  s   t | jd d S )z|Return the number of bits in the encryption algorithm.

        e.g. if the algorithm is AES-256, this returns 256.
        r8   r   )lenr   r'   r   r   r   bits   s   zEncryptionInfo.bitsN)r   r   )r"   r#   )r"   r
   )r"   r4   )r   r   r   r   r!   propertyr%   r)   r*   r.   r1   r3   r7   r8   r:   r   r   r   r   r   ?   s*    
r   c                   @  sd   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   r?   r   r@   r%   DEFAULT_PERMISSIONSrB   rC   rD   r   r   r   r   r<      s   
 r<   )r   
__future__r   systypingr   r   r   r   version_infor	   Ztyping_extensionsZpikepdf._qpdfr
   r   rE   r   r<   r   r   r   r   <module>   s   
(P