Click here to Skip to main content
15,888,066 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
hello
How can i encrypt and decrypt pdf file using AES-256 in C# with itextsharp
thanks
Posted
Comments
Sergey Alexandrovich Kryukov 5-Dec-14 3:23am    
Why? What do you want to achieve by this encryption? Note that this is a symmetric algorithm...
—SA
BillWoodruff 5-Dec-14 4:31am    
Why aren't you reading the documentation on iTextSharp, or searching CodeProject, or doing a Google search on these specific questions ?

1 solution

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
 
Share this answer
 
Comments
BillWoodruff 5-Dec-14 4:48am    
iTextSharp has its own support pdf creation, encryption, decryption, as the OP would have easily found out if they had read the documentation, or done a simple Google search :

"ENCRYPT YOUR DOCUMENTS

If you want to secure your documents, you can encrypt them using passwords (low security) or certificates (high security). Given the right credentials, you can also use iText to decrypt secured PDFs."
Sergey Alexandrovich Kryukov 5-Dec-14 12:44pm    
Good point; would you post your own answer of that?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900