Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Encryption/Decryption with .NET

0.00/5 (No votes)
23 Jun 2002 3  
Encryption/Decryption with .NET

Encryption and Decryption

The System.Security.Cryptographic namespace within the Microsoft .NET Framework provides a variety of tools to aid in encryption and decryption. The CryptoStream class is used here to demonstrate the encryption and decryption with System.Security.Cryptographic.SymmetricAlgorithm, such as DESCryptoServiceProvider, RC2CryptoServiceProvider, and RijndaelManaged classes.

I have searched the Internet for some samples and all I found were based on the Microsoft sample code in KB Article Q307010, which basically uses input/output files as source and destination. I would like to have the encryption and decryption done in memory without having to specify source and destination files, so that I could use the code on a web server or so.

After I posted the original code, I found some interesting things about .NET System.Security.Cryptographic.SymmetricAlgorithm classes that they are not able to handle characters which are special to Url. (Don't know why). Therefore, I modified the source code to make it work. I have received a lot of emails regarding "Bad Data" exceptions, when some special characters are contained in the data or key. I emailed my updated code back, but haven't updated the code posted here. Looks like I have to update the code here as well.

For any questions, please contact me at: fangfrank@hotmail.com and I would be happy to answer them a.s.a.p.

Revision History

26 Jun 2002 - Initial Revision

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here