Can i break Adobe PDF password encryption with RC4/AES 128bits?

送分小仙女□ 提交于 2019-12-11 18:21:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!