EncryptFile

安全與簽章

描述

加密磁碟上的檔案並將結果存成新檔。整份文件不必載入記憶體,因此可用來加密超大文件

語法

Delphi

Function TPDFlib.EncryptFile(Const InputFileName, OutputFileName, Owner, User: WideString; Strength, Permissions: Integer): Integer;

ActiveX

Function PDFlib::EncryptFile(InputFileName As String, OutputFileName As String, Owner As String, User As String, Strength As Long, Permissions As Long) As Long

DLL

int DLEncryptFile(int InstanceID, const wchar_t * InputFileName, const wchar_t * OutputFileName, const wchar_t * Owner, const wchar_t * User, int Strength, int Permissions);

參數

InputFileName要加密的檔案名稱。
OutputFileName要建立的目的地檔名。
Owner加密檔案使用的所有者密碼,有時稱為 "master" 密碼或 "permissions" 密碼,變更文件時需要它。 加密檔案使用的使用者密碼,有時稱為 "open" 密碼,讓使用者能開啟文件,但不能以未允許的方式使用文件。
User
Strength要使用的加密強度:0 = 40 位元 RC4 加密 1 = 128 位元 RC4 加密 2 = 128 位元 AES 加密(需要 Acrobat 7 以上) 3 = 256 位元 AES 加密(需要 Acrobat 9 以上) 4 = 256 位元 AES 加密(需要 Acrobat X 以上) 5 = 256 位元 AES-GCM 認證加密(需要支援 ISO TS 32003 的 PDF 2.0)
Permissions以 EncodePermissions 函式建立的值

傳回值

0無法加密檔案。請查看 LastErrorCode 的結果
1文件加密成功

備註

強度選 4 或 5 時,先呼叫 SetPDFMACEnabled 即可附加獨立的 PDF MAC 完整性權杖