CryptoSys API Library Manual

TDEA_Hex

TDEA_Hex encrypts or decrypts data represented as a hexadecimal string using a key represented in hexadecimal notation. The process is carried out in one step in Electronic Codebook (EBC) mode.

VB6/VBA Syntax

Public Declare Function TDEA_Hex Lib "diCryptoSys.dll" (ByVal strOutput As String, ByVal strInput As String, ByVal strKey As String, ByVal bEncrypt As Boolean) As Long

nRet = TDEA_Hex(strOutput, strInput, strKey, bEncrypt)

Parameters

strOutput
[out] String of sufficient length to receive the output.
strInput
[in] String containing the input data in hexadecimal.
strKey
[in] String containing the key in hexadecimal.
bEncrypt
[in] Boolean direction flag: set as True to encrypt or False to decrypt.

C/C++ Syntax

long _stdcall TDEA_Hex(char *lpszOutput, const char *lpszInput, const char *lpszKey, int bEncrypt);

Returns (VB6/C)

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

Remarks

The length of the input string strInput 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. The key string strKey must be exactly 48 hex characters long (i.e. representing exactly 24 bytes). The parity bit is ignored. The output string strOutput must be set up with at least the same number of characters as the input string before calling. The variables strOutput and strInput should be different. Valid hexadecimal characters are [0-9A-Fa-f].

Example

    Dim nRet As Long
    Dim strOutput As String
    Dim strInput As String
    Dim strKey As String
    Dim bEncrypt As Boolean
    Dim sCorrect As String

    strInput = "8000000000000000"
    strKey = "010101010101010101010101010101010101010101010101"
    sCorrect = "95F8A5E5DD31D900"
    ' Set strOutput to be same length as strInput
    strOutput = String(Len(strInput), " ")

    Debug.Print "KY="; strKey
    Debug.Print "PT="; strInput
    ' Encrypt
    nRet = TDEA_Hex(strOutput, strInput, strKey, ENCRYPT)
    Debug.Print "CT="; strOutput, "Return value="; nRet
    Debug.Print "OK="; sCorrect

    ' Decrypt back
    strInput = strOutput
    nRet = TDEA_Hex(strOutput, strInput, strKey, DECRYPT)
    Debug.Print "P'="; strOutput, "Return value="; nRet

This should result in output as follows:

KY=010101010101010101010101010101010101010101010101
PT=8000000000000000
CT=95F8A5E5DD31D900         Return value= 0
OK=95F8A5E5DD31D900
P'=8000000000000000         Return value= 0

See Also

TDEA_HexMode

[Contents] [Index]

[HOME]   [NEXT: TDEA_HexMode...]

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