使用下面的代码我可以为 PDF 文件设置密码但是应该不区分大小写,如何设置不区分大小写的密码?
string InputFile = strFilePath;
string OutputFile = strFilePathEncrypt;
using (Stream input = new FileStream(InputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
{
PdfReader reader = new PdfReader(input);
PdfEncryptor.Encrypt(reader, output, false, strPDFPassword, "secret", PdfWriter.ALLOW_SCREENREADERS);
reader.Close();
}
}
最佳答案
使用 PDF 规范中的标准加密算法无法完成您想做的事情。
PDF 允许使用两种算法之一加密文档,RC4 或 AES。两种算法都是 symetric-key algorithms ,这意味着它们使用相同的 key 来加密和解密数据。为了“不区分大小写”,您需要有几个可能的 key 来解密相同的数据,这两种算法都不允许这样做。
关于c# - 如何为 PDF 文件设置不区分大小写的密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30053711/