다음을 통해 공유


Back to MSSecurity library again

If you have seen my previous post about the class library that I developed to encrypt text or files using symmetric encryption (Rijndael algorithm). So you would already know that it was developed using .NET Framework 1.1. I've upgraded the library to .NET Framework 2.0 and fixed a bug I discovered in the decryption methods.

I already described the methods in this library before so allow me to copy-and-paste them from my previous post

The library called MSecurityLibrary and it consists of only two classes

Encryption: does the symmetric encryption using Rijndael algorithm and a key size of 256 bits.

Hashing: hash any string with MD5 hashing algorithms

Encryption class has 11 public methods. I'll describe the main functions here.

public void encryptFile(string sourceFile,string distinationFile,string password)

public void encryptFile(string sourceFile,string distinationFile,byte[] key)

These two methods encrypt a file using either a password or an array of bytes as a key. You can use the generateKey() method to generate that key and save it in a file (usually should be put in a floppy disk to make it more secure).

public void decryptFile(string sourceFile,string distinationFile,string password)

public void decryptFile(string sourceFile,string distinationFile,byte[] key)

These two methods are the opposite of the others. They decrypt a file using either a password or a key.

public string encryptString(string inputString,string password)

public string encryptString(string inputString,byte[] key)

These two do the same but for strings. They take inputString parameter which will be encrypted using a password or a key

public string decryptString(string inputString,string password)

public string decryptString(string inputString,byte[] key)

The opposite to the previous two methods,

Hashing class has only one public method

public string HashStringWithMD5(string password)

This method takes a string and hashes it using MD5 algorithms and returns a string. This method is very powerful if you want to hash passwords in a database in case you want to save them secured.

The new version of the library can be found here. If you want to take a look at the source code, you will find it here.

I developed a windows application to encrypt and decrypt files or entire folders based on this library and I'm planning to post it with the full source code in my next post (God Willing).

See you in the next post sooooon J

//Mohamed Sharaf

Comments

  • Anonymous
    May 29, 2007
    The comment has been removed

  • Anonymous
    June 20, 2007
    As I promised in my last post, here's the MS File Encryption program based on the MSSecurity Library

  • Anonymous
    June 20, 2007
    I just tested your library with IronPython. Checkout the URL to my blog. I think you need to discard extra NULL bytes when decrypting a string.