如何为PDF文件设置不区分大小写的密码?(How to set a case insensitive password to a PDF file?)

编程入门 行业动态 更新时间:2024-10-24 08:21:34
如何为PDF文件设置不区分大小写的密码?(How to set a case insensitive password to a PDF file?)

使用以下代码我可以设置密码为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.

更多推荐

本文发布于:2023-08-02 19:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1380658.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大小写   何为   密码   文件   PDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!