[VB6 equivalent: TDEA_BytesMode
]
Dim sOutput As String Dim sInput As String Dim sKey As String Dim sHexIV As String Dim sCorrect As String Dim aKey() As Byte Dim aResult() As Byte Dim aData() As Byte Dim aInitV() As Byte sKey = "0123456789abcdeffedcba987654321089abcdef01234567" sHexIV = "1234567890abcdef" sInput = "Now is the time for all " sCorrect = "204011f986e35647199e47af391620c5bb9a5bcfc86db0bb" ' Convert hex strings to byte arrays aKey = Cnv.FromHex(sKey) aInitV = Cnv.FromHex(sHexIV) ' Convert string to byte array aData = System.Text.Encoding.Default.GetBytes(sInput) Console.WriteLine("KY=" & Cnv.ToHex(aKey)) Console.WriteLine("IV=" & Cnv.ToHex(aInitV)) Console.WriteLine("PT=" & "[" & sInput & "]") ' Encrypt in one-off process aResult = Tdea.Encrypt(aData, aKey, Mode.CBC, aInitV) Console.WriteLine("CT=" & Cnv.ToHex(aResult) & " " & General.ErrorCode) Console.WriteLine("OK=" & sCorrect) ' Now decrypt back aData = Tdea.Decrypt(aResult, aKey, Mode.CBC, aInitV) sOutput = System.Text.Encoding.Default.GetString(aData) Console.WriteLine("P'=" & "[" & sOutput & "]" & " " & General.ErrorCode)
See Also:
Tdea.Decrypt Method (Byte[], Byte[], Mode, Byte[])
Tdea.Encrypt Method (Byte[], Byte[], Mode, Byte[])