Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
PDF 문서를 암호화하면 외부의 무단 접근으로부터 내용을 보호할 수 있으며, 특히 파일 공유나 아카이빙 중에 유용합니다.
기밀 PDF 문서는 암호화되고 비밀번호로 보호될 수 있습니다. 비밀번호를 아는 사용자만 이러한 문서를 복호화하고 열어볼 수 있습니다.
Aspose.PDF 라이브러리를 사용하여 PDF 암호화가 어떻게 작동하는지 살펴보겠습니다.
PDF 파일을 암호화하려면 PdfFileSecurity 객체를 생성한 다음 EncryptFile 메서드를 호출해야 합니다. EncryptFile 메서드에 사용자 비밀번호, 소유자 비밀번호 및 권한을 전달할 수 있습니다. 이 메서드에 KeySize 및 Algorithm 값을 전달해야 합니다.
다음은 가능한 CryptoAlgorithm 목록입니다:
멤버 이름 | 값 | 설명 |
---|---|---|
RC4x40 | 0 | 키 길이 40의 RC4. |
RC4x128 | 1 | 키 길이 128의 RC4. |
AESx128 | 2 | 키 길이 128의 AES. |
AESx256 | 3 | 키 길이 256의 AES. |
다음 코드 스니펫은 PDF 파일을 암호화하는 방법을 보여줍니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void EncryptPDFFile()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
using (var fileSecurity = new Aspose.Pdf.Facades.PdfFileSecurity())
{
// Bind PDF document
fileSecurity.BindPdf(dataDir + "input.pdf");
// Encrypt file using 256-bit encryption
fileSecurity.EncryptFile("User_P@ssw0rd", "OwnerP@ssw0rd", Aspose.Pdf.Facades.DocumentPrivilege.Print, Aspose.Pdf.Facades.KeySize.x256,
Aspose.Pdf.Facades.Algorithm.AES);
// Save PDF document
fileSecurity.Save(dataDir + "SampleEncrypted_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.