.Net Encryption Simplified

Most of the projects that I work on require encryption of some form. Usually Symmetric (the kind where you can use the same password to both encrypt and decrypt), but sometimes asymmetric as well (where you encrypt with one password and decrypt with another). the .Net Framework has rich support for many different types of encryption algorithms, of varying methods and strengths, giving tons of options over how to run an exact implementation. However, one look at the System.Security.Cryptography namespace in the framework can end up leaving the novice user scratching his or her head over how exactly to proceed. Even individual implementation examples found on MSDN regarding individual algorithms are complicated pieces of code. Despite the wealth of code relating to this topic in the Framework, there is no one method (as far as I know) where you can simply put in data and a key, and receive encrypted text in response.

There are of course different explanations on the Internet regarding how to implement actual encyption on your program. For the past few projects I have been using an article on the 4Guys website (Using Symmetric Cryptography in an ASP.NET Web Page) as a guide for implementing Symmetric encryption in my applications. However, either because of a quirk in the algorithm or in my specific implementation of the algorithm, the encryption was throwing errors whenever I was trying to encrypt a string with a space in it. I was in need of a new wrapper implementation for encryption.

I found this on the Code Project website, in an article titled .Net Encryption Simplified by wumpus1 (AKA Jeff Atwood). Jeff created a some classes to wrap basically all of the encryption algorithms for all types (hash, assymetric, symmetric) in the .Net framework. These classes enable a much easier introduction of practical encryption into an application. (Additionally, one can learn alot about the mechanics behind the different encryption methods by going through the code that is included. I have also translated the Assymetric portion of the code base into C# – if anyone wants a copy, let me know). For anyone who wants to use encryption in their .Net application but is baffled regarding how exactly to use the resources included in the .Net framework, I recommend that you give this article and code a look.

Tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *