?? encoderimplbase.h
字號(hào):
/*!
\file EncoderImplBase.h
\author Jackson
\date 13/1/2005
*/
#ifndef _LUCID_ENCRYPTION_ENCODERIMPLBASE_H_
#define _LUCID_ENCRYPTION_ENCODERIMPLBASE_H_
#ifdef _MSC_VER
# include <mbstring.h>
#endif
#include "ShareLib.h"
#include <string.h>
#include "EncodeAlgorithm.h"
namespace Lucid {
namespace Encryption {
//! \class TEncoderImplBase
/*!
\brief Encoder implementation interface
*/
class TEncoderImplBase {
public:
enum {
MAX_KEY_LEN = 16,
MAX_IV_LEN = 16
};
//! Constructor
/*!
\param key key for encryption
\param key_length length of key
\param iv initial vector encryption
\param iv_length length of initial vector
\param algorithm encode algorithm used
*/
TEncoderImplBase(const unsigned char* key, unsigned int key_length, const unsigned char* iv = 0, unsigned int iv_length = 0, TEncodeAlgorithm algorithm = NO_ENCODE) : mKeyLength(key_length), mIVLength(iv_length), mAlgorithm(algorithm) {
#ifdef _MSC_VER
_mbsncpy(mKey, key, key_length);
#else
strncpy((char*)mKey, (char*)key, key_length);
#endif
if (iv) {
#ifdef _MSC_VER
_mbsncpy(mIV, iv, iv_length);
#else
strncpy((char*)mIV, (char*)iv, iv_length);
#endif
}
}
//! Desstructor
/*!
*/
virtual ~TEncoderImplBase() {}
/*!
\brief encode input byte array
\param input input byte array
\param output output byte array
\param input_len length of input array
\param output_len length of output array
*/
virtual void Encode(const unsigned char* input, unsigned char* output, const int input_len, int& output_len) = 0;
/*!
\brief decode input byte array
\param input input byte array
\param output output byte array
\param input_len length of input array
\param output_len length of output array
*/
virtual void Decode(const unsigned char* input, unsigned char* output, const int input_len, int& output_len) = 0;
/*!
\brief get the key for encryption/ decryption
*/
const unsigned char* GetKey() const {
return mKey;
}
/*!
\brief get the key length for encryption/ decryption
*/
unsigned int GetKeyLength() const {
return mKeyLength;
}
/*!
\brief get the initial vector for encryption/ decryption
*/
const unsigned char* GetIV() const {
return mIV;
}
/*!
\brief get the initial vector length for encryption/ decryption
*/
unsigned int GetIVLength() const {
return mIVLength;
}
/*!
\brief get the algorithm for encryption/ decryption
*/
TEncodeAlgorithm GetAlgorithm() const {
return mAlgorithm;
}
private:
unsigned char mKey[MAX_KEY_LEN];
unsigned char mIV[MAX_IV_LEN];
unsigned int mKeyLength;
unsigned int mIVLength;
TEncodeAlgorithm mAlgorithm;
};
}
}
#endif // _LUCID_ENCRYPTION_ENCODERIMPLBASE_H_
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -