Carries out the Blowfish transformation function on a hexadecimal string according to the direction and mode set up by an earlier call to BLF_Init or BLF_InitHex.
VB6/VBA
Debug.Print "Testing BLF_UpdateHex ..." Dim nRet As Long Dim hContext As Long Dim strKey As String Dim strHexString As String Dim sCorrect As String strKey = "0123456789abcdef" Debug.Print "KY=", strKey ' Initialise the context hContext = BLF_InitHex(strKey, True, "ECB", "") If hContext = 0 Then ' Always check for error MsgBox "Unable to initialise BLF context", vbCritical Exit Sub End If ' "Now is t" strHexString = "4e6f772069732074" Debug.Print "PT=", strHexString nRet = BLF_UpdateHex(hContext, strHexString) Debug.Print "CT=", strHexString Debug.Print "OK=", "cb08e682c67e32e2" ' "he time for all" strHexString = "68652074696d6520666f7220616c6c20" Debug.Print "PT=", strHexString nRet = BLF_UpdateHex(hContext, strHexString) Debug.Print "CT=", strHexString Debug.Print "OK=", "8fcb010ac2ce9b1d9c4538762e33b52f" nRet = BLF_Final(hContext)
Output
Testing BLF_UpdateHex ... KY= 0123456789abcdef PT= 4e6f772069732074 CT= CB08E682C67E32E2 OK= cb08e682c67e32e2 PT= 68652074696d6520666f7220616c6c20 CT= 8FCB010AC2CE9B1D9C4538762E33B52F OK= 8fcb010ac2ce9b1d9c4538762e33b52f
VB.NET
Console.WriteLine("Testing BLF_UpdateHex ...") Dim nRet As Integer ''Dim hContext As Integer Dim strKey As String Dim strHexString As String ''Dim sCorrect As String Dim oBlowfish As Blowfish = Blowfish.Instance() strKey = "0123456789abcdef" Console.WriteLine("KY=" & " " & strKey) ' Initialise the context nRet = oBlowfish.InitEncrypt(strKey, Mode.ECB, Nothing) If nRet <> 0 Then ' Always check for error MsgBox("Unable to initialise BLF context", vbCritical) Exit Sub End If ' "Now is t" strHexString = "4e6f772069732074" Console.WriteLine("PT=" & " " & strHexString) strHexString = oBlowfish.Update(strHexString) Console.WriteLine("CT=" & " " & strHexString) Console.WriteLine("OK=" & " " & "cb08e682c67e32e2") ' "he time for all" strHexString = "68652074696d6520666f7220616c6c20" Console.WriteLine("PT=" & " " & strHexString) strHexString = oBlowfish.Update(strHexString) Console.WriteLine("CT=" & " " & strHexString) Console.WriteLine("OK=" & " " & "8fcb010ac2ce9b1d9c4538762e33b52f") oBlowfish.Dispose()
[Contents]