Marine Library  1.0
C++ library for Linux Networking Development
Public Types | Public Member Functions | List of all members
CEncryptorAes Class Reference

A convenient interface for Advanced Encryption Standard (AES) algorithm. More...

#include <encrypt_aes.hh>

Public Types

enum  EKeyIntensity { L128 = 128, L192 = 192, L256 = 256 }
 Key sizes.
 

Public Member Functions

 CEncryptorAes ()
 Construct a default object. More...
 
 CEncryptorAes (const std::string &key, EKeyIntensity intensity)
 Construct an object. More...
 
void setIntensity (EKeyIntensity intensity)
 Set key size. More...
 
void setKey (const std::string &key)
 Set encryption key (password). More...
 
void setKeyAndIntensity (const std::string &key, EKeyIntensity intensity)
 Set encryption key (password) and key size. More...
 
Encryption

Encrypt given data.

If from is non-zero, first from bytes of input will NOT be encrypted, i.e. data between input.begin() and input.begin()+from will be copied to output straightly, and data between input.begin()+from and input.end() will be encrypted and append to output.

Parameters
[in]inputData to be encrypted
[out]outputA buffer to receive the result
[in]fromIndex in input from where data will be encrypted
Returns
  • 0: Succeeded
  • -1: Invalid parameter
int encrypt (const std::vector< char > &input, std::vector< char > &output, size_t from=0) const
 
int encrypt (const std::vector< signed char > &input, std::vector< signed char > &output, size_t from=0) const
 
int encrypt (const std::vector< unsigned char > &input, std::vector< unsigned char > &output, size_t from=0) const
 
int encrypt (const std::string &input, std::string &output, size_t from=0) const
 
Decryption

Decrypt given data.

If from is non-zero, first from bytes of input will NOT be decrypted, i.e. data between input.begin() and input.begin()+from will be copied to output straightly, and data between input.begin()+from and input.end() will be decrypted and append to output.

Parameters
[in]inputData to be decrypted
[out]outputA buffer to receive the result
[in]fromIndex in input from where data will be decrypted
Returns
  • 0: Succeeded
  • -1: Invalid parameter
  • -2: Input data format error
int decrypt (const std::vector< char > &input, std::vector< char > &output, size_t from=0) const
 
int decrypt (const std::vector< signed char > &input, std::vector< signed char > &output, size_t from=0) const
 
int decrypt (const std::vector< unsigned char > &input, std::vector< unsigned char > &output, size_t from=0) const
 
int decrypt (const std::string &input, std::string &output, size_t from=0) const
 

Detailed Description

A convenient interface for Advanced Encryption Standard (AES) algorithm.

Note
CEncryptorAes object can NOT be copied.

Constructor & Destructor Documentation

CEncryptorAes::CEncryptorAes ( )
inline

Construct a default object.

Key size defaults to L128.
You need setKey or setKeyAndIntensity before encryption/decryption operations.

CEncryptorAes::CEncryptorAes ( const std::string &  key,
EKeyIntensity  intensity 
)
inline

Construct an object.

Parameters
keyEncryption key (password)
intensityKey size

Member Function Documentation

void CEncryptorAes::setIntensity ( EKeyIntensity  intensity)
inline

Set key size.

Parameters
intensityKey size
void CEncryptorAes::setKey ( const std::string &  key)
inline

Set encryption key (password).

Password is an arbitrary string.

Parameters
keyEncryption key (password)
void CEncryptorAes::setKeyAndIntensity ( const std::string &  key,
EKeyIntensity  intensity 
)
inline

Set encryption key (password) and key size.

Password is an arbitrary string.

Parameters
keyEncryption key (password)
intensityKey size

The documentation for this class was generated from the following file: