如何使用itextsharp在C#中加密pdf文件AES-256 [英] How to encrypt pdf file AES-256 in C# with itextsharp

查看:199
本文介绍了如何使用itextsharp在C#中加密pdf文件AES-256的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

如何在C#中使用AES-256加密和解密pdf文件with itextsharp

谢谢

解决方案

请参阅我对该问题的评论。我想到的第一个想法是:它没有任何实际意义。这是对称算法: http://en.wikipedia.org/wiki/Symmetric-key_algorithm [ ^ ]。



由于相同的密钥用于加密和解密,因此您无法进行数字签名,也无法通过公共通信渠道发送数据来保护数据。为什么?因为,如果你想保护它,你需要秘密发送密钥。但是,如果您有办法秘密发送密钥,您可以以相同的方式发送文件。



非对称公钥加密是一个完全不同的故事:您可以执行密钥交换,就像任何监视所有通信并获得您发送的所有密钥的人无法读取文件,如果您保护其内容,或者无法进行密钥交换那样如果您使用数字签名,伪造虚假文件。如果你认为这是不可能的,你就不知道现代密码学是如何工作的。所以,请理解这个想法: http://en.wikipedia.org/wiki/Public-key_cryptography [< a href =http://en.wikipedia.org/wiki/Public-key_cryptographytarget =_ blanktitle =New Window> ^ ]。



关于任何这些算法的实现,使用.NET这不是问题:

http://msdn.microsoft.com/en-us/library/system.security.cryptography%28v=vs.110%29。 aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm%28v=vs.110%29.aspx [<一个HREF =http://msdn.microsoft.com/en-us/library/system.se curity.cryptography.symmetricalgorithm%28v = vs.110%29.aspxtarget =_ blanktitle =New Window> ^ ],

http://msdn.microsoft.com/en-us/library/system .security.cryptography.asymmetricalgorithm%28v = vs.110%29.aspx [ ^ ]。



-SA

hello
How can i encrypt and decrypt pdf file using AES-256 in C# with itextsharp
thanks

解决方案

Please see my comment to the question. First idea which comes to my mind: it makes no practical sense. This is a symmetric algorithm: http://en.wikipedia.org/wiki/Symmetric-key_algorithm[^].

As the same key is used for encryption and decryption, you cannot make digital signature, and you cannot protect the data by sending it using the public channels of communication. Why? Because, if you want to protect it, you need to send the key secretly. But if you had a way to send a key secretly, you could send the file itself in the same way.

Asymmetric public-key cryptography is a completely different story: you could perform the key exchange the way that anyone who spied on all your communications and get all the key you sent would not be able to read the file, if you protect its content, or would not be able to forge the false document, if you used digital signature. If you thought it's impossible, you have no clue how modern cryptography works. So, please get this idea: http://en.wikipedia.org/wiki/Public-key_cryptography[^].

As to the implementation of any of those algorithms, with .NET this is not a problem:
http://msdn.microsoft.com/en-us/library/system.security.cryptography%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.security.cryptography.asymmetricalgorithm%28v=vs.110%29.aspx[^].

—SA


这篇关于如何使用itextsharp在C#中加密pdf文件AES-256的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆