EncryptionUtils

EncryptionUtils

概述

EncryptionUtils 是 Aspose.PDF FOSS 中用于 Python 的类。

用于 PDF 兼容的 AES-CBC、RC4 加密和密钥派生的实用类。

此类为在 Python 程序中处理 EncryptionUtils 对象提供了 15 种方法。可用的方法包括:compute_file_encryption_key、compute_hash_v5、compute_owner_key_v4、compute_user_key_v4、compute_user_owner_keys_v6、decrypt_aes_cbc、decrypt_rc4、decrypt_writer_encrypted_stream、derive_object_key、encrypt_aes_cbc、encrypt_perms_v6、encrypt_rc4,以及另外 3 种方法。安装 Aspose.PDF FOSS for Python 包后,所有公共成员对任何 Python 应用程序均可访问。

方法

签名描述
`encrypt_aes_cbc(key: bytes, data: bytes, iv: bytesNone)→bytes`
decrypt_aes_cbc(key: bytes, data: bytes) → bytes解密由 encrypt_aes_cbc 加密的数据。
encrypt_rc4(key: bytes, data: bytes) → bytes使用 RC4(ARC4)算法加密数据。
decrypt_rc4(key: bytes, data: bytes) → bytes使用 RC4(ARC4)算法解密数据。
decrypt_writer_encrypted_stream(file_key: bytes, algorithm: str, obj_id: int, data: bytes) → bytes解密由 :meth:PdfWriterV0._encrypt_data 产生的流字节。
compute_owner_key_v4(owner_password: str, user_password: str, key_length: int, revision: int) → bytes根据算法 3.3 计算所有者密码值 (O)。
compute_file_encryption_key(password: str, o_value: bytes, p_value: int, file_id: bytes, key_length: int, revision: int, encrypt_metadata: bool) → bytes根据算法 3.2 计算文件加密密钥。
compute_user_key_v4(password: str, o_value: bytes, p_value: int, file_id: bytes, key_length: int, revision: int, encrypt_metadata: bool) → tuple[bytes, bytes]根据算法 3.4/3.5 计算用户密码值 (U) 和加密密钥。
verify_password_v4(password: str, u_value: bytes, o_value: bytes, p_value: int, file_id: bytes, key_length: int, revision: int, encrypt_metadata: bool) → `bytesNone`
compute_hash_v5(password: bytes, salt: bytes, user_key: bytes) → bytes根据算法 2.B(ISO 32000-2)计算 V5/R6 的哈希值。
`compute_user_owner_keys_v6(user_password: str, owner_password: str, file_key: bytesNone)→tuple[bytes, bytes, bytes, bytes]`
verify_password_v6(password: str, u_value: bytes, o_value: bytes, ue_value: bytes, oe_value: bytes) → `bytesNone`
encrypt_perms_v6(file_key: bytes, p_value: int, encrypt_metadata: bool) → bytes为 R6 加密权限和元数据标志。
derive_object_key(file_key: bytes, obj_num: int, gen_num: int, use_aes: bool) → bytes根据算法 3.1 派生对象特定密钥。
generate_file_id() → bytes为新文档生成随机的 16 字节文件 ID。

另请参阅

 中文