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()
.
Public Declare Function BLF_UpdateHex Lib "diCryptoSys.dll"
(ByVal hContext As Long, ByVal strHexString As String) As Long
nRet = BLF_UpdateHex(hContext, strHexString)
long __stdcall BLF_UpdateHex(long hContext, char *szHexData);
BLF_Init()
or BLF_InitHex()
.If successful, the return value is 0; otherwise it returns a non-zero error code.
Blowfish.Update Method (String)
szHexString must be a multiple of 16 hex characters long (i.e. representing a multiple of 8 bytes). If not, an error code will be returned. Valid hexadecimal characters are [0-9A-Fa-f]. Note that the output overwrites the input. szHexString must be a variable that can receive the output, not a constant.
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 Function 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)
This should result in output as follows:
KY=0123456789abcdef PT=4e6f772069732074 CT=CB08E682C67E32E2 OK=cb08e682c67e32e2 PT=68652074696d6520666f7220616c6c20 CT=8FCB010AC2CE9B1D9C4538762E33B52F OK=8fcb010ac2ce9b1d9c4538762e33b52f
BLF_Init
BLF_InitHex
BLF_Update
BLF_Final