[VB6 equivalent: BLF_B64Mode]
Dim nRet As Integer Dim strOutput As String Dim strInput As String Dim strKey As String Dim strIV As String Dim sCorrect As String ' "7654321 Now is the time for " padded to 32 bytes with 4 nulls strInput = "NzY1NDMyMSBOb3cgaXMgdGhlIHRpbWUgZm9yIAAAAAA=" sCorrect = "a3e01jAG3uYFsVbidAOXk1jeuecVRhbZWfFlK9X/ksw=" ' Key is 0x0123456789ABCDEFF0E1D2C3B4A59687 strKey = "ASNFZ4mrze/w4dLDtKWWhw==" ' IV is 0xFEDCBA9876543210 strIV = "/ty6mHZUMhA=" ' Set strOutput to be same length as strInput Console.WriteLine("KY=" & " " & strKey) Console.WriteLine("IV=" & " " & strIV) Console.WriteLine("PT=" & " " & strInput) ' Encrypt in one-off process strOutput = Blowfish.Encrypt(strInput, strKey, Mode.CBC, strIV, EncodingBase.Base64) Console.WriteLine("CT=" & " " & strOutput & " " & nRet) Console.WriteLine("OK=" & " " & sCorrect) ' Now decrypt back to plain text strInput = strOutput strOutput = Blowfish.Decrypt(strInput, strKey, Mode.CBC, strIV, EncodingBase.Base64) Console.WriteLine("P'=" & " " & strOutput & " " & nRet)
See Also:
Blowfish.Decrypt Method (String, String, Mode, String, EncodingBase)
Blowfish.Encrypt Method (String, String, Mode, String, EncodingBase)