4#include <QLoggingCategory> 
    6#if defined (HAVE_OPENSSL) 
   10#include "RabbitCommonEncrypt.h" 
   14static Q_LOGGING_CATEGORY(log, 
"RabbitCommon.Encrypt")
 
   16#define PASSWORD_LENGTH 16 
   18static const unsigned char Key[] =
 
   20    0x56, 0x9a, 0x28, 0x12, 0xfa, 0x59, 0xa1, 0x58,
 
   21    0x65, 0x7c, 0xc8, 0x92, 0x1a, 0x09, 0x10, 0x8a
 
   24CEncrypt::CEncrypt(
const char* pszPassword)
 
   26    SetPassword(pszPassword);
 
   33int CEncrypt::SetPassword(
const char* pszPassword)
 
   35    size_t nLen = PASSWORD_LENGTH;
 
   36    if(nLen > strlen(pszPassword))
 
   37        nLen = strlen(pszPassword);
 
   39    m_szPassword.resize(PASSWORD_LENGTH, 0);
 
   40    memcpy(&m_szPassword[0], Key, PASSWORD_LENGTH);
 
   41    for(
int i = 0; i < nLen; i++)
 
   43        m_szPassword[i] ^= pszPassword[i];
 
   52    QString szIn = QString::fromStdString(std::string(pIn, inLen));
 
   54    nRet = 
Encode(szIn, szOut);
 
   56    outLen = szOut.length();
 
   57    *pOut = 
new char[outLen];
 
   58    memcpy(*pOut, szOut.data(), outLen);
 
 
   65#if defined (HAVE_OPENSSL) 
   67    QByteArray in = szIn.toUtf8();
 
   68        bool b = aes.ecb_encrypt(in, szOut,
 
   69                        QByteArray::fromStdString(m_szPassword));
 
   77    szOut = szIn.toUtf8();
 
   85#if defined (HAVE_OPENSSL) 
   88    bool b = aes.ecb_encrypt(szIn, out,
 
   89                    QByteArray::fromStdString(m_szPassword),
 
  110    QByteArray in(pIn, inLen);
 
  113    if(nRet) 
return nRet;
 
  114    outLen = out.length();
 
  115    *pOut = 
new char[outLen];
 
  116    memcpy(*pOut, out.data(), outLen);
 
 
  125    nRet = 
Dencode(pIn, inLen, &pOut, nOutLen);
 
  128        qCritical(log) << 
"Dencode error";
 
int Encode(const char *pIn, const int &inLen, char **pOut, int &outLen)
 
int Dencode(const char *pIn, const int &inLen, char **pOut, int &outLen)