Encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation.
VB6/VBA
Debug.Print "Testing BLF_Hex ..." Dim nRet As Long Dim strOutput As String Dim strInput As String Dim strKey As String Dim sCorrect As String strInput = "0123456789ABCDEF" strKey = "FEDCBA9876543210" sCorrect = "0ACEAB0FC6A0A28D" ' Set strOutput to be same length as strInput strOutput = String(Len(strInput), " ") Debug.Print "KY=", strKey Debug.Print "PT=", strInput ' Encrypt in one-off process nRet = BLF_Hex(strOutput, strInput, strKey, ENCRYPT) Debug.Print "CT=", strOutput Debug.Print "OK=", sCorrect ' Now decrypt back to plain text strInput = strOutput nRet = BLF_Hex(strOutput, strInput, strKey, DECRYPT) Debug.Print "P'=", strOutput
Output
Testing BLF_Hex ... KY= FEDCBA9876543210 PT= 0123456789ABCDEF CT= 0ACEAB0FC6A0A28D OK= 0ACEAB0FC6A0A28D P'= 0123456789ABCDEF
VB.NET
Console.WriteLine("Testing BLF_Hex ...") ''Dim nRet As Integer Dim strOutput As String Dim strInput As String Dim strKey As String Dim sCorrect As String strInput = "0123456789ABCDEF" strKey = "FEDCBA9876543210" sCorrect = "0ACEAB0FC6A0A28D" ' Set strOutput to be same length as strInput ''strOutput = String(Len(strInput), " ") Console.WriteLine("KY=" & " " & strKey) Console.WriteLine("PT=" & " " & strInput) ' Encrypt in one-off process strOutput = Blowfish.Encrypt(strInput, strKey, Mode.ECB, Nothing) Console.WriteLine("CT=" & " " & strOutput) Console.WriteLine("OK=" & " " & sCorrect) ' Now decrypt back to plain text strInput = strOutput strOutput = Blowfish.Decrypt(strInput, strKey, Mode.ECB, Nothing) Console.WriteLine("P'=" & " " & strOutput)
[Contents]