CryptoSys API Library Manual

BLF_UpdateHex

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 Syntax

Public Declare Function BLF_UpdateHex Lib "diCryptoSys.dll" (ByVal hContext As Long, ByVal strHexString As String) As Long

nRet = BLF_UpdateHex(hContext, strHexString)

Parameters

hContext
[in] Long handle to the BLF context set up by an earlier call to BLF_Init or BLF_InitHex.
strHexString
[in/out] String containing input in hexadecimal format to be processed by the BLF function and to receive the output.

C/C++ Syntax

long _stdcall BLF_UpdateHex(long ctx_handle, char *sHexData);

Returns (VB6/C)

Long: If successful, the return value is 0; otherwise it returns a non-zero error code.

.NET Equivalent

Blowfish.Update Method (String)

Remarks

strHexString 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. strHexString must be a variable that can receive the output, not a constant.

Example

    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

See Also

BLF_Init BLF_InitHex BLF_Update BLF_Final

[Contents] [Index]

[HOME]   [NEXT: CNV_B64Filter...]

Copyright © 2001-11 D.I. Management Services Pty Ltd. All rights reserved.