使用密码加密和解密c#中的文件 [英] Encrypt and Decrypt the files in c# with password

查看:133
本文介绍了使用密码加密和解密c#中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试用c#编写一个程序来密码保护文件,这样如果用密码加密文件就无法打开文件。用户将使用密码对文件进行加密。



让我们举个例子,用户使用C#加密密码为123456的excel文件。我的要求是当用户打开excel时,如果用户输入正确的密码,它将弹出密码,它将解密并显示excel数据。



我的问题是文件的方式



我想做的是密码保护文件后(excel,pdf,txt等..),每当有人点击打开文件时,它都会询问他的密码。输入正确的密码后解密文件。





注意:我可以在c#中进行加密和解密,但在这种情况下解密必须发生在文件。

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.

推荐答案

有一些链接可能有助于你完成这项任务....





加密/解密文件或字符串 [ ^ ]



加密和用C#解密数据 [ ^ ]



简单的加密和解密d ata in C# [ ^ ]



如何在c#中创建密码加密解密 [ ^ ]



希望通过这些可以得到任何想法....





乐于帮助...
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...


你在谈论推杆密码进入Excel / Word类型的文件?然后,您可能需要使用宏来实现此目的。目前我正在做类似的事情,但我坚持在某一点上&也许这里有人可以帮助我......请参考这里:

在Excel中使用VBA通过C#禁用保存功能 [ ^ ]
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#[^]


这篇关于使用密码加密和解密c#中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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