CryptoSys API Library Manual

BLF_Init

Initialises the context with the key, direction and mode ready for repeated operations of the BLF_Update or BLF_UpdateHex functions. The key and IV data are provided in byte arrays.

VBA/VB6 Syntax

Public Declare Function BLF_Init Lib "diCryptoSys.dll" (ByRef lpKey As Byte, ByVal nKeyLen As Long, ByVal bEncrypt As Boolean, ByVal strMode As String, ByRef lpInitV As Byte) As Long

hContext = BLF_Init(abKey(0), nKeyLen, bEncrypt, strMode, abInitV(0))

C/C++ Syntax

long __stdcall BLF_Init(const unsigned char *lpKey, long keyBytes, int fEncrypt, const char *szMode, const unsigned char *lpIV);

Parameters

lpKey
[in] array containing the key.
keyBytes
[in] containing the length of the key in bytes.
fEncrypt
[in] direction flag: set as ENCRYPT (True) to encrypt or DECRYPT (False) to decrypt.
szMode
[in] 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.
lpIV
[in] array containing the initialization vector (IV), or zero (0) for ECB mode.

Returns (VBA/C)

Non-zero handle of the context hContext to be used in subsequent calls to the functions BLF_Update, BLF_UpdateHex or BLF_Final. Returns zero if an error occurs.

.NET Equivalent

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

Remarks

The initialization vector byte array lpInitV must be exactly the block size of 8 bytes long, except for ECB mode, where it is ignored (use 0). The key array lpKey can be any length between 1 and 56 bytes (448 bits). Unlike most other functions in this API, BLF_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 BLF_Update or BLF_UpdateHex.

Example

See BLF_Update.

See Also

BLF_InitHex BLF_UpdateHex BLF_Update BLF_Final

[Contents] [Index]

[PREV: BLF_HexMode...]   [Contents]   [Index]   
   [NEXT: BLF_InitError...]

Copyright © 2001-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-07T07:42:00Z.