1 Star 0 Fork 0

xiaqiu / 加解密学习

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CryptTask.cpp 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
xiaqiu 提交于 2024-05-05 13:46 . first commit
#include "CryptTask.h"
#include "crypt.h"
#include <chrono>
#include <iostream>
#include <memory>
#include <thread>
//初始化加解密秘钥
void CryptTask::Init(std::string passwd){
enc_ = std::make_shared<Crypt>();
enc_->Init(passwd);
}
void CryptTask::Main(){
std::cout<<"begin CryptTask::Main()"<<std::endl;
while(!is_exit_){
auto data = PopFront();
if(!data){
std::this_thread::sleep_for(std::chrono::milliseconds(10));
continue;
}
auto out = Data::Make(mem_pool_);
int outsize = data->size() + enc_->getPadding(data->size());
int data_size = 0;
bool is_end = data->end();
out->New(outsize);
if(is_encrypt_){
data_size = enc_->Encrypt((char*)data->data(), data->size(), (char*)out->data(),is_end);
}else{
data_size = enc_->Encrypt((char*)data->data(), data->size(), (char*)out->data(),is_end);
}
out->set_size(data_size);
std::cout<<"<"<<out->size()<<">"<<std::flush;
out->set_end(data->end());
if(next_){
next_->PushBack(out);
}
if(data->end()){
break;
}
}
std::cout<<"begin CryptTask::End()"<<std::endl;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mrxiao_com/DES_study.git
git@gitee.com:mrxiao_com/DES_study.git
mrxiao_com
DES_study
加解密学习
main

搜索帮助

344bd9b3 5694891 D2dac590 5694891