CryptoSys API Library Manual

AES128_InitHex

Initialises the context with the key, direction and mode ready for repeated operations of the AES function. The key and IV data are passed in hexadecimal format.

VB6/VBA Syntax

Public Declare Function AES128_InitHex Lib "diCryptoSys.dll" (ByVal strHexKey As String, ByVal bEncrypt As Boolean, ByVal strMode As String, ByVal strHexIV As String) As Long

hContext = AES128_InitHex(strHexKey, bEncrypt, strMode, strHexIV)

Parameters

strHexKey
[in] String containing the key in hexadecimal representation.
bEncrypt
[in] Boolean direction flag: set as True to encrypt or False to decrypt.
strMode
[in] String specifying the confidentiality mode:
"ECB" for Electronic Codebook mode,
"CBC" for Cipher Block Chaining mode,
"CFB" for 128-bit Cipher Feedback mode,
"OFB" for Output Feedback mode, or
"CTR" for Counter mode.
strIV
[in] String containing the initialization vector in hexadecimal.

C/C++ Syntax

long _stdcall AES128_InitHex(const char *lpszKey, int bEncrypt, const char *lpszMode, const char *lpszIV);

Returns (VB6/C)

Long: non-zero handle of the context hContext to be used in subsequent calls to the functions AES128_Update, AES128_UpdateHex or AES128_Final. Returns zero if an error occurs.

.NET Equivalent

Aes128.InitEncrypt Method (String, Mode, String)
Aes128.InitDecrypt Method (String, Mode, String)

Remarks

The key string strHexKey must be exactly 32 hexadecimal characters long (i.e. representing exactly 16 bytes/128 bits). The initialization vector strHexIV must be exactly 32 hexadecimal characters long (i.e. representing exactly the block size of 16 bytes), except for ECB mode, where it is ignored (use ""). Valid hexadecimal characters are [0-9A-Fa-f]. Unlike most other functions in this API, AES128_InitHex returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling the AES Update function.

Example

See AES128_UpdateHex.

See Also

AES128_Init AES128_UpdateHex AES128_Update AES128_Final

[Contents] [Index]

[HOME]   [NEXT: AES128_Update...]

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