Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear all,
I am using visual studio 2010 and work in windows application. i need to encrypt the existing pdf files any one give me the reference for do it.

Thanks advance.

Regards,
Karthik M

What I have tried:

I am tried to encrypt the existing pdf file.
Posted
Updated 27-May-16 2:18am
Comments
F-ES Sitecore 27-May-16 7:41am    
Google "encrypt file c#" and you'll find lots of examples.
Jewel-Davis 23-Jun-16 5:56am    
I'm not sure if the suggested answers work for you or are you looking for something else. The PDF files itself have a support for encryption, see this article about PDF Encryption done in .NET (the article uses this .NET library for word and pdf files).

Microsoft itself gently provides sample code: Encrypting Data[^].
 
Share this answer
 
If you wish to do a custom encryption of a file (any file), you need to do the following:

1) Open the file in binary mode
2) Read data (character or block, as appropriate for your algorithm)
3) Apply you custom encryption algorithm to data
4) Write to 'new' file.
5) Repeat 3, 4, 5 until entire file is processed
6) Close source and target files.

Now - there are many improvements that can be made, such as keeping the entire original file in memory, encrypting, and then overwriting the source, but that depends upon what you want to do. There are also pre-written algorithm, such as DES, to do much of the work for you.
 
Share this answer
 

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