开发者

Using RSACryptoServiceProvider in C# to encrypt/decrypt an excel file?

How can I use private/public keys for encryption/decryption of an an excel file in C#.NET?

The article RSA Encryption in C# describes a way of doing this encryption, but this example only works for encrypting/decrypting text, not for an excel file.

How can I encrypt / decrypt an excel file (using asym开发者_JS百科metric RSA encryption)?


The link you provide is not the way you should use RSA to encrypt data (such as a file). I have an old (but still up to date) blog entry on the subject:

http://pages.infinit.net/ctech/20031101-0151.html


One way...

In the EncryptData method of that article it accepts a string to be encrypted which it then converts to bytes before encrypting it. To get the bytes from a file, you can use a FileStream.

Simply change the method so that the parameter is a filepath instead of text data, and use the filestream to Read/Write bytes as required. Likewise for the DecryptData method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜