Rijndael Encryption in VB.NET
Author: Intelligent Solutions Inc.
Version Compatibility: Visual Basic.NET
Dim sEnc As String sEnc = EncryptText("This is a test value", _ "This is my secret key") Debug.WriteLine(sEnc) Debug.WriteLine(DecryptText(sEnc, _ "This is my secret key"))
Thanks to Ron Beauchemin for updating this code (22 May 2003) to correct a bug whereby extraneous null characters were added at the end of the decrypted string. This created problems if you decrypted a string from an encrypted row in a database, displayed the string on the form and later reencrypted the string from the form and used it to access the original row in the database. In this case, the row was not found. Ron tracked this down to the fact the original decryption function did not strip off trailing nulls created by the CryptoStream object.
Instructions: Copy the declarations and code below and paste directly into your VB project.