Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been trying to make a program in c# to password protect a file so nobody can open the file if it has been encrypted by password. User will encrypt the file with password.

Lets take an example, user encrypted an excel file with password as 123456 using C#. My requirement is when the user open the excel it will popup for the password if user enters the correct password, it will decrypt and show the excel data.

My questions is how the file

What I want to do is that after password protecting the file(excel, pdf,txt etc..), whenever somebody click to open the file, it will ask him for the password. After entering correct password decrypt the files.


Note: I am able to do encryption and decryption in c#, but in this case decryption has to happen at file.
Posted
Comments
Shubh Agrahari 25-Feb-13 3:02am    
something you worked on this...??
Member 7911797 25-Feb-13 3:51am    
In the above links decryption is also happening in c# code. My requirement is encrypt file with password and send it to user.User don'h have any windows or web application, we are sending output files through mail or shared folder. When user opens the file(eg. excel) it will prompt for password, when he enter correct password it ha to decrypt and show the file. Here decryption has to happen at file level.

there is some links that may help for your this task....


Encrypt/Decrypt File or String[^]

Encrypt and Decrypt Data with C#[^]

Simple encrypting and decrypting data in C#[^]

how to create password encrypt decrypt in c#[^]

hope will get any idea by these....


happy to help...
 
Share this answer
 
Comments
Member 7911797 25-Feb-13 3:45am    
In the above links decryption is also happening in c# code. My requirement is encrypt file with password and send it to user.User don'h have any windows or web application, we are sending output files through mail or shared folder. When user opens the file(eg. excel) it will prompt for password, when he enter correct password it ha to decrypt and show the file. Here decryption has to happen at file level.
Shubh Agrahari 25-Feb-13 3:50am    
dude this is possible with a specific programming platform without any platform how we integrate that requirement with file......why you are not using file security tools that could help you better.....
Are you talking about putting a password into Excel/Word type of file? Then you might need to use Macro for that purposes. Currently I'm working on something similar but I stuck at certain point & perhaps someone from here can help me on that...refer here :
Disable Save functionality in Excel with VBA through C#[^]
 
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