问题
I've encrypted some pdf files with iTextsharp lib and using AES 128bits and key length = 16bytes(protect reading).Can anyone break password or some app can do that? Thank so much.
回答1:
You can set 2 kinds of possible "passwords" here:
- Read password
- Edit/Modify password
Using an "edit password" is not secure at all, because it's possible to read the whole file (even without knowing the password, by using PdfReader.unethicalreading = true;
) and then creating a new unencrypted one:
using System.IO;
using iTextSharp.text.pdf;
namespace PdfDecryptorCore
{
public class PasswordDecryptor
{
public string ReadPassword { set; get; }
public string PdfPath { set; get; }
public string OutputPdf { set; get; }
public void DecryptPdf()
{
PdfReader.unethicalreading = true;
PdfReader reader;
if(string.IsNullOrWhiteSpace(ReadPassword))
reader = new PdfReader(PdfPath);
else
reader = new PdfReader(PdfPath, System.Text.Encoding.UTF8.GetBytes(ReadPassword));
using (var stamper = new PdfStamper(reader, new FileStream(OutputPdf, FileMode.Create)))
{
stamper.Close();
}
}
}
}
来源:https://stackoverflow.com/questions/10163199/can-i-break-adobe-pdf-password-encryption-with-rc4-aes-128bits