
    OAi                        S r SSKJr  SSKJrJrJrJrJr  \(       a  SSK	J
r
   " S S\5      r\" 5       r " S S5      r " S	 S
\5      rg)zFor managing PDF encryption.    )annotations)TYPE_CHECKINGAnyLiteral
NamedTuplecast)EncryptionMethodc                      \ rS rSr% SrSrS\S'    SrS\S'    SrS\S'    Sr	S\S	'    Sr
S\S
'    SrS\S'    SrS\S'    SrS\S'   Srg)Permissions   aJ  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_highres N)__name__
__module____qualname____firstlineno____doc__r   __annotations__r   r   r   r   r   r   r   __static_attributes__r       U/var/www/html/land-ocr/venv/lib/python3.13/site-packages/pikepdf/models/encryption.pyr   r      sv     M4 GT%"t"'!OT!.K#L$(L$9M4:r   r   c                      \ rS rSrSrSS jr\SS j5       r\SS j5       r\SS j5       r	\SS j5       r
\SS j5       r\SS	 j5       r\SS
 j5       r\SS j5       r\SS j5       rS rSrg)EncryptionInfo?   zReports 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.
c                    Xl         g)zInitialize EncryptionInfo.

Generally pikepdf will initialize and return it.

Args:
    encdict: Python dictionary containing encryption settings.
N_encdict)selfencdicts     r   __init__EncryptionInfo.__init__G   s	      r   c                2    [        U R                  S   5      $ )z(Revision number of the security handler.Rintr%   r&   s    r   r+   EncryptionInfo.RQ        4==%&&r   c                2    [        U R                  S   5      $ )z"Version of PDF password algorithm.Vr,   r.   s    r   r2   EncryptionInfo.VV   r0   r   c                2    [        U R                  S   5      $ )z@Return encoded permission bits.

See :meth:`Pdf.allow` instead.
Pr,   r.   s    r   r5   EncryptionInfo.P[   s     4==%&&r   c                4    [        SU R                  S   5      $ )z)Encryption method used to encode streams.r	   streamr   r%   r.   s    r   stream_methodEncryptionInfo.stream_methodc        &h(?@@r   c                4    [        SU R                  S   5      $ )z)Encryption method used to encode strings.r	   stringr9   r.   s    r   string_methodEncryptionInfo.string_methodh   r<   r   c                4    [        SU R                  S   5      $ )z0Encryption method used to encode the whole file.r	   filer9   r.   s    r   file_methodEncryptionInfo.file_methodm   s     &f(=>>r   c                2    [        U R                  S   5      $ )a  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bytesr%   r.   s    r   user_passwordEncryptionInfo.user_passwordr   s     T]]=122r   c                2    [        U R                  S   5      $ )z8Return the RC4 or AES encryption key used for this file.encryption_keyrG   r.   s    r   rL   EncryptionInfo.encryption_key   s     T]]#3455r   c                8    [        U R                  S   5      S-  $ )zlReturn the number of bits in the encryption algorithm.

e.g. if the algorithm is AES-256, this returns 256.
rL      )lenr%   r.   s    r   bitsEncryptionInfo.bits   s     4==!123a77r   c                2   SU R                   R                   SU R                  < SU R                  < SU R                  < SU R
                  < SU R                  < SU R                  < SU R                  < S	U R                  < S
U R                  < S3$ )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+   r2   r5   r:   r?   rC   rI   rL   rQ   r.   s    r   __repr__EncryptionInfo.__repr__   s    ''(
466):dffYj	 J#!!##9d&8&8%: ;!!!7D$6$6#8 9$""$Mtyyl!5	
r   r$   N)r'   zdict[str, Any])returnr-   )rY   r	   )rY   rH   )r   r   r   r   r   r(   propertyr+   r2   r5   r:   r?   rC   rI   rL   rQ   rW   r   r   r   r   r!   r!   ?   s      ' ' ' ' ' ' A A A A ? ? 
3 
3 6 6 8 8
r   r!   c                  x    \ rS rSr% SrSrS\S'    SrS\S'    SrS\S	'    \	r
S
\S'    SrS\S'    SrS\S'   Srg)
Encryption   z=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metadatar   N)r   r   r   r   r   r`   r   ra   r+   DEFAULT_PERMISSIONSrc   rd   re   r   r   r   r   r\   r\      sh    GE3O6
 D#N3
 !"A!
 -E;,< C? Hd<r   r\   N)r   
__future__r   typingr   r   r   r   r   pikepdf._corer	   r   rf   r!   r\   r   r   r   <module>rj      sI    # " @ @.+;* +;\ "m S
 S
l!< !<r   