Ok if I do a simple datareader and print each row in my test column (encrypted) I get the value as expected.
What I am looking to do is simply take the returned value, pass it to the Decrypt function of the TripleDES class and print the decrypted value. I encrypted some random text into my "TEST" column.
This is the error I receive:
Unable to cast object of type 'System.String' to type 'System.Byte'.
I could use CByte() but that converts it to a byte and not an array of bytes.
'Decrypt Info Sub Decrypt() 'Connection variables Dim strConnection As String = ConfigurationManager.ConnectionStrings("messengerConnectionString").ConnectionString Dim sqlConnection As New MySqlConnection(strConnection) Dim SQLQuery As String = "SELECT * from testing" Dim command As New MySqlCommand(SQLQuery, sqlConnection) Dim dr As MySqlDataReader 'Encryption variable Dim TDES As New TripleDES() 'Open DB Connection & read sqlConnection.Open() dr = command.ExecuteReader(CommandBehavior.CloseConnection) Dim decrypt As String = Nothing If dr.HasRows Then While dr.Read() decrypt = TDES.Decrypt(dr.Item("TEST")) MsgBox(decrypt) End While End If End Sub