背景
项目中用到了websocket,第三方api需要对请求的参数进行cbc加密,就搜索到了这些工具和代码,代码下载下来,自己优化了部分代码,能适应更多的场景。
便捷工具
Websocket在线模拟请求工具
在线AES加密解密
md5加密
在线时间戳
代码上传到此,注意其中有三个变量 一个是 Max变量,支持输入的字符串最大长度,
static void setKey(std::string& key);
static void setIv(std::string& Iv);
static std::string getKey();
static std::string getIv(); 还有这四个函数
static string strKey; //密码
static string strIv; //iv 偏移量
主要是设置密码和偏移,目前是密码和偏移都是一个值,没具体研究,简单的当作工具来使用了
使用方式如下:
std::string test = "abcdefg";
std::string result;
std::string key = "02d5d368b6169188";
CRijndael::setKey(key);
CRijndael::setIv(key);
CRijndael::EncryptString(test,result);
qDebug()<<"final_encode= "<< QString::fromStdString(result);
std::string final_decode = decryt(result,"");
qDebug()<<"final_decode= "<< QString::fromStdString(final_decode);
代码地址
QT ces cbc 加密解密