[VB6 equivalent: BLF_BytesMode]
Dim strInput As String
Dim strKey As String
Dim strHexIV As String
Dim sCorrect As String
Dim abKey() As Byte
Dim abOutput() As Byte
Dim abData() As Byte
Dim abInitV() As Byte
strKey = "0123456789ABCDEFF0E1D2C3B4A59687"
strHexIV = "FEDCBA9876543210"
strInput = _
"37363534333231204E6F77206973207468652074696D6520666F722000000000"
sCorrect = _
"6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC"
' Convert to byte arrays and compute lengths
abKey = Cnv.FromHex(strKey)
abData = Cnv.FromHex(strInput)
abInitV = Cnv.FromHex(strHexIV)
' Dimension array for output
Console.WriteLine("KY=" & " " & Cnv.ToHex(abKey))
Console.WriteLine("IV=" & " " & Cnv.ToHex(abInitV))
Console.WriteLine("PT=" & " " & Cnv.ToHex(abData))
' Encrypt in one-off process
abOutput = Blowfish.Encrypt(abData, abKey, Mode.CBC, abInitV)
Console.WriteLine("CT=" & " " & Cnv.ToHex(abOutput))
Console.WriteLine("OK=" & " " & sCorrect)
' Now decrypt back
abOutput = Blowfish.Decrypt(abData, abKey, Mode.CBC, abInitV)
Console.WriteLine("P'=" & " " & Cnv.ToHex(abData))
See Also:
Blowfish.Decrypt Method (Byte[], Byte[], Mode, Byte[])
Blowfish.Encrypt Method (Byte[], Byte[], Mode, Byte[])