ENC.jpg


The attached sample code encrypts your file by 16 and 32 key secret and decrypts back by 16 and 32 Key. The algorithm used to encrypt and decrypt is Rijndael.

The Rijndael class in .NET Framework is used for this purpose.


Include #using System.Security.Cryptography namespace in your project before you can use the class. The sample code looks like the following:


Rijndael alg = Rijndael.Create();
alg.Key = pdb.GetBytes(16);

alg.IV = pdb.GetBytes(16);
CryptoStream cs = new CryptoStream(ms, alg.CreateEncryptor(), CryptoStreamMode.Write);

cs.Write(clearBytes, 0, clearBytes.Length);
cs.Close();
byte[] encryptedData = ms.ToArray();


ANOTHER LINKS:

http://mfc-project.blogfa.com/post-23.aspx

OR:

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7468&lngWId=10


ENJOY IT.