使用以下代码我可以设置密码为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(); } }Using following code i can set password to PDF Files but that should be Case insensitive, How to set case insensitive password?
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两种算法之一加密文档。 两种算法都是对称密钥算法 ,这意味着它们使用相同的密钥来加密和解密数据。 为了具有“不区分大小写”,您需要有几个可以解密相同数据的密钥,这两个算法都不允许这样的事情。
What you want to do cannot be done by using standard encryption algorithms from the PDF specification.
PDF allows encrypting the document using one of two algorithms, RC4 or AES. Both algorithms are symetric-key algorithms, meaning that they use the same key for encrypting and decrypting the data. In order to have "case insensivity", you would need to have several possible keys that can decrypt the same data, none of these two algorithms allow such thing.
更多推荐
发布评论