QuickCrypt Library C++ Interface

CBlowfish::CBlowfish

CBlowfish( SL_CIPHER_DIR dir, const unsigned char* pKey );

CBlowfish( SL_CIPHER_DIR dir, const unsigned char* pKey, unsigned int nKeyLen );

Parameters

dir

    [in] Cipher direction. It can be SLC_ENCRYPT or SLC_DECRYPT.

 pKey

    [in] Pointer to the secret key.

 nKeyLen

    [in] Length in bytes of the key. It can be in the range 1 through 72 bytes.

Remarks

Both constructors create a new CBlowfish object and initialize it with the secret key pointed by pKey. Note that if nKeyLen it is not indicated, the first CBlowfish::DEFAULTKEYSIZE bytes of the memory buffer pointed by pKey are used as the secret key.

The CBlowfish object is initialized for encryption if dir is SLC_ENCRYPT, or it is initialized for decryption if dir is SLC_DECRYPT.

Example

 

//Define the key for Blowfish encryption algorithm
char key[CBlowfish::DEFAULTKEYSIZE] = 
{
    'v','e','r','y','l','o','n','g',
    'p','a','s','s','w','o','r','d',
    '0','1','2','3','4','5','6','7',
    '9','8','7','7','7','2','2','1',
    '0','0','0','1','1','2','2','2',
    '2','3','5','6','5','6','3','3',
    '2','2','1','1','1','7','7','7'
};
//Declare a local CBlowfish object
CBlowfish cipher( SLC_ENCRYPT, (const unsigned char*)key );

//Declare a dynamic CBlowfish object
CBlowfish* pCipher = new CBlowfish( SLC_DECRYPT, (const unsigned char*)key, 16 );

 

 

CBlowfish Overview   |   Class Members   |   Useful Links

 

See Also    CBlowfish::ProcessBlock


 

 

Send Feedback to SlavaSoft Inc. Tell a friend about QuickCrypt Library