[VB6 equivalent: BLF_Bytes]
Dim strInput As String Dim strKey As String Dim sCorrect As String Dim abKey() As Byte Dim abOutput() As Byte Dim abData() As Byte ' Define test vectors in hex strKey = "FEDCBA9876543210" strInput = "0123456789ABCDEF0123456789ABCDEF" sCorrect = "0ACEAB0FC6A0A28D0ACEAB0FC6A0A28D" ' Convert to byte arrays and compute lengths abKey = Cnv.FromHex(strKey) abData = Cnv.FromHex(strInput) ' Dimension array for output Console.WriteLine("KY=" & " " & Cnv.ToHex(abKey)) Console.WriteLine("PT=" & " " & Cnv.ToHex(abData)) ' Encrypt in one-off process abOutput = Blowfish.Encrypt(abData, abKey, Mode.ECB, Nothing) Console.WriteLine("CT=" & " " & Cnv.ToHex(abOutput)) Console.WriteLine("OK=" & " " & sCorrect) ' Now decrypt back abOutput = Blowfish.Decrypt(abData, abKey, Mode.ECB, Nothing) Console.WriteLine("P'=" & " " & Cnv.ToHex(abData))
See Also:
Blowfish.Decrypt Method (Byte[], Byte[], Mode, Byte[])
Blowfish.Encrypt Method (Byte[], Byte[], Mode, Byte[])