CryptoSys API Library Manual

DES_Init

Initialises the context with the key, direction and mode ready for repeated operations of the DES function. The key and IV data are provided in byte arrays.

VB6/VBA Syntax

Public Declare Function DES_Init Lib "diCryptoSys.dll" (ByRef abKey As Byte, ByVal bEncrypt As Boolean, ByVal strMode As String, ByRef abInitV As Byte) As Long

hContext = DES_Init(abKey, bEncrypt, strMode, abInitV)

Parameters

abKey
[in] Byte array containing the key.
nKeyLen
[in] Long containing the length of the key in bytes.
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 64-bit Cipher Feedback mode,
"OFB" for Output Feedback mode, or
"CTR" for Counter mode.
abInitV
[in] Byte array containing the initialization vector (IV), or zero (0) for ECB mode.

C/C++ Syntax

long _stdcall DES_Init(const unsigned char *key, int bEncrypt, const char *lpszMode, const unsigned char *iv);

Returns (VB6/C)

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

.NET Equivalent

Des.InitEncrypt Method (Byte[], Mode, Byte[])
Des.InitDecrypt Method (Byte[], Mode, Byte[])

Remarks

The key abKey must be exactly 24 bytes long and the IV, if required, exactly 8 bytes long. Unlike most other functions in this API, DES_Init returns zero if an error occurs. It is important to check that the value of hContext returned is not equal to zero before calling a DES_Update function.

Example

See DES_Update.

See Also

DES_InitHex DES_UpdateHex DES_Update DES_Final

[Contents] [Index]

[HOME]   [NEXT: DES_InitError...]

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