#include "Secret.h" Secret::Secret(): secretkey(NULL) { this->secretkey=new char[36]; this->secretkey[0]=0x2b; this->secretkey[1]=0xef; this->secretkey[2]=0x33; this->secretkey[3]=0xaf; this->secretkey[4]=0x2b; this->secretkey[5]=0x4c; this->secretkey[6]=0x91; this->secretkey[7]=0xb6; this->secretkey[8]=0xac; this->secretkey[9]=0xe5; this->secretkey[10]=0xca; this->secretkey[11]=0x21; this->secretkey[12]=0xc4; this->secretkey[13]=0xb5; this->secretkey[14]=0xbe; this->secretkey[15]=0x5d; this->secretkey[16]=0x7c; this->secretkey[17]=0x3c; this->secretkey[18]=0xc3; this->secretkey[19]=0x16; this->secretkey[20]=0x29; this->secretkey[21]=0x7b; this->secretkey[22]=0x8a; this->secretkey[23]=0x99; this->secretkey[24]=0x3e; this->secretkey[25]=0x90; this->secretkey[26]=0xce; this->secretkey[27]=0x37; this->secretkey[28]=0xf8; this->secretkey[29]=0x8f; this->secretkey[30]=0xec; this->secretkey[31]=0x84; this->secretkey[32]=0xcf; this->secretkey[33]=0xf1; this->secretkey[34]=0x74; this->secretkey[35]=0x26; } Secret::~Secret() { if(NULL!=this->secretkey) { delete[] this->secretkey; } } QByteArray Secret::getEncodeString(const QString& str) { QByteArray data(str.toUtf8()); QDate currentDate=QDate::currentDate(); int day; day=currentDate.day()%16+1; QByteArray newData; int keyInd=0; //newData.reserve(data.size()+data.size()/day+10); for(int i=0;isecretkey[keyInd%36]) )+500); keyInd++; //qDebug()<secretkey[keyInd%1]<<"\n"; //newData.push_back( (data.at(i))+00); if(i%day==0) { QTime t; t= QTime::currentTime(); for(int k=0;k<3;k++) { qsrand(t.msec()+t.second()*1000); int n = qrand(); QByteArray md5=QCryptographicHash::hash(QString("%1").arg(n).toLatin1(), QCryptographicHash::Md5); newData.push_back(md5[0]); newData.push_back(md5[1]); newData.push_back(md5[2]); newData.push_back(md5[3]); newData.push_back(md5[4]); newData.push_back(md5[5]); qsrand(t.msec()+t.second()*1000+n); md5=QCryptographicHash::hash(QString("%1").arg(n).toLatin1(), QCryptographicHash::Md5); newData.push_back(md5[6]); newData.push_back(md5[7]); newData.push_back(md5[8]); newData.push_back(md5[9]); newData.push_back(md5[10]); newData.push_back(md5[11]); md5=QCryptographicHash::hash(QString("%1").arg(n).toLatin1(), QCryptographicHash::Md5); newData.push_back(md5[12]); newData.push_back(md5[0]); newData.push_back(md5[2]); newData.push_back(md5[4]); newData.push_back(md5[6]); newData.push_back(md5[8]); } } } return newData.toHex(); } QString Secret::getDecodeString(const QByteArray& code) { QByteArray data=QByteArray::fromHex(code); QByteArray newData; QDate currentDate=QDate::currentDate(); int day; day=currentDate.day()%16+1; int keyInd=0; for(int i=0;isecretkey[keyInd%36])); keyInd++; } if(i%day==0) { i+=54; continue; } } //return data; return QString(newData); }