44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#ifndef AESCLASS
|
|
#define AESCLASS
|
|
#include <iomanip>
|
|
#include "../cryptopp563/cryptlib.h"
|
|
#include "../cryptopp563/modes.h"
|
|
#include "../cryptopp563/aes.h"
|
|
#include "../cryptopp563/filters.h"
|
|
#include "../cryptopp563/base64.h"
|
|
#include <string>
|
|
class AESClass
|
|
{
|
|
private:
|
|
byte key[CryptoPP::AES::DEFAULT_KEYLENGTH];
|
|
byte iv[CryptoPP::AES::BLOCKSIZE];
|
|
|
|
public:
|
|
AESClass();
|
|
~AESClass();
|
|
void setKey(byte* _key);
|
|
void setKey(const char *_key);
|
|
void setKey(std::string _key);
|
|
void setIv(byte* _iv);
|
|
void setIv(const char *_iv);
|
|
void setIv(std::string _iv);
|
|
const byte* getKey() const;
|
|
const byte* getIv() const;
|
|
const int getKeyLength() const;
|
|
const int getBlockSize() const;
|
|
std::string AESEncrypt(std::string plaintext);
|
|
std::string AESEncrypt(char *_plaintext);
|
|
|
|
std::string AESDecrypt(byte* _ciphertext);
|
|
std::string AESDecrypt(std::string _ciphertext);
|
|
static void hex2byte(const char *in, unsigned int len, byte *out);
|
|
static std::string toBase64(byte* _ciphertext);
|
|
static std::string toBase64(std::string _ciphertext);
|
|
void base64toByte(std::string text, byte* out);
|
|
std::string base64toString(std::string text);
|
|
};
|
|
|
|
|
|
#endif // AESCLASS
|
|
|