既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上C C++开发知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
memset(aes_keybuf,0,sizeof(aes_keybuf));
strcpy((char *)aes_keybuf, "zeng");
cout << "current aes_keybuf value is :" << aes_keybuf << endl;
AES_KEY aeskey;
AES_set_encrypt_key(aes_keybuf,256,&aeskey);
AES_encrypt(buf,buf2,&aeskey);
cout << "current buf2 value is :" << buf2 << endl;
memset(aes_keybuf,0,sizeof(aes_keybuf));
strcpy((char *)aes_keybuf, "zeng2");
cout << "current aes_keybuf value is :" << aes_keybuf << endl;
AES_set_decrypt_key(aes_keybuf,256,&aeskey);
AES_decrypt(buf2,buf3,&aeskey);
cout << "current buf3 value is :" << buf3 << endl;
if(memcmp(buf,buf3,sizeof(buf))==0)
printf("test success\r\n");
else
printf("test fail\r\n");
}
// 测试使用aes加密文件算法的例子
int TestAesEncryptFile(std::string in_file_path, std::string out_file_path,
const char *rc4_encrypt_key, int encrypt_chunk_size = 16)
{
ifstream fin(in_file_path.c_str(), ios::binary);
ofstream fout(out_file_path, ios::binary);
if(!fin)
{
cout << "Can not open fin file." << endl;
return 1;
}
if(!fout)
{
cout << "Can not open fout file." << endl;
return 1;
}
//用指定密钥对一段内存进行加密,结果放在outbuffer中
unsigned char aes_keybuf[32];
memset(aes_keybuf,0,sizeof(aes_keybuf));
strcpy((char *)aes_keybuf, "zengraoli");
AES_KEY aeskey;
AES_set_encrypt_key(aes_keybuf, 256, &aeskey);
char *in_data = new char[encrypt_chunk_size + 1];
char *out_data = new char[encrypt_chunk_size + 1];
while(!fin.eof())
{
fin.read(in_data, encrypt_chunk_size);
if(fin.gcount() < encrypt_chunk_size)
{
fout.write(in_data, fin.gcount());
}
else
{
AES_encrypt((const unsigned char *)in_data, (unsigned char *)out_data, &aeskey);
fout.write(out_data, fin.gcount());
}
};
fout.close();
fin.close();
RELESE_ARRAY(in_data);
RELESE_ARRAY(out_data);
return 0;
}
// 测试使用aes解密文件算法的例子
int TestAesDecryptFile(std::string in_file_path, std::string out_file_path,
const char *rc4_dencrypt_key, int encrypt_chunk_size = 16)
{
ifstream fin(in_file_path.c_str(), ios::binary);
ofstream fout(out_file_path, ios::binary);
if(!fin)
{
cout << "Can not open fin file." << endl;
return 1;
}
if(!fout)
{
cout << "Can not open fout file." << endl;
return 1;
}
//用指定密钥对一段内存进行加密,结果放在outbuffer中
unsigned char aes_keybuf[32];
memset(aes_keybuf,0,sizeof(aes_keybuf));
strcpy((char *)aes_keybuf, "zengraoli");
AES_KEY aeskey;
AES_set_decrypt_key(aes_keybuf, 256, &aeskey);
char *in_data = new char[encrypt_chunk_size + 1];
char *out_data = new char[encrypt_chunk_size + 1];
int i = 0;
while( ! fin.eof() )
{
fin.read(in_data, encrypt_chunk_size);
if(fin.gcount() < encrypt_chunk_size)
{
fout.write(in_data, fin.gcount());
}
else
{
AES_decrypt((unsigned char *)in_data, (unsigned char *)out_data, &aeskey);
fout.write(out_data, fin.gcount());
}
};
fout.close();
fin.close();
RELESE_ARRAY(in_data);
RELESE_ARRAY(out_data);
return 0;
}
// 测试使用aes加密算法的例子
void TestRsaEncrypt()
{
BIGNUM b={0};
RSA* pRsa = RSA_generate_key(1024, RSA_F4, 0, 0);
//pRsa中包含了N D,你这里自己修改就可以了
char in_data[] = "zengraoli";
cout << "current in_data value is : " << in_data << endl;
int len = RSA_size(pRsa);
char* out_data = new char[len];
memset(out_data, 0, len);
RSA_public_encrypt( sizeof(in_data), (unsigned char *)in_data,
(unsigned char *)out_data, pRsa, RSA_PKCS1_PADDING);
cout << "current out_data value is : " << out_data << endl;
char out[1024] = {0};
RSA_private_decrypt(len, (unsigned char *)out_data,
(unsigned char *)out, pRsa, RSA_PKCS1_PADDING);
RSA_free(pRsa);
cout << "current out value is : " << out << endl;
}
// 测试使用rc4加密算法的例子
void TestRc4Encrypt()
{
char code[64]={0};
int codelen = sizeof(code);
memcpy_s(code, 64, “This is secrect”, 15);
cout << "before encrypt :" << code << endl;
unsigned char *outbuffer = new unsigned char[codelen];
//用指定密钥对一段内存进行加密,结果放在outbuffer中
RC4_KEY rc4_key;
RC4_set_key(&rc4_key,7,(unsigned char *)"zenraoli");
RC4(&rc4_key,codelen,(unsigned char *)code,outbuffer);
cout << "after encrypt :" << outbuffer << endl;
//用指定密钥对outbuffer中的密文进行解密,结果放回原来的内存
memset(code,0,sizeof(code));
RC4_set_key(&rc4_key,7,(unsigned char *)"zenraoli");//这里必须再次设置密钥
RC4(&rc4_key,codelen,outbuffer,(unsigned char *)code);
cout << "after decrypt :" << code << endl;
if (outbuffer)
{
delete[] outbuffer;
outbuffer = NULL;
}
}
// 测试使用rc4加密文件算法的例子
int TestRc4EncryptFile(std::string in_file_path, std::string out_file_path,
const char *rc4_encrypt_key, int encrypt_chunk_size = 16)
{
ifstream fin(in_file_path.c_str(), ios::binary);
ofstream fout(out_file_path, ios::binary);
if(!fin)
{
cout << "Can not open fin file." << endl;
return 1;
}
if(!fout)
{
cout << "Can not open fout file." << endl;
return 1;
}
//用指定密钥对一段内存进行加密,结果放在outbuffer中
char code[64] = {0};
int codelen = sizeof(code);
RC4_KEY rc4_key;
RC4_set_key(&rc4_key, strlen(rc4_encrypt_key), (unsigned char *)rc4_encrypt_key);
char *in_data = new char[encrypt_chunk_size + 1];
char *out_data = new char[encrypt_chunk_size + 1];
while(!fin.eof())
{
fin.read(in_data, encrypt_chunk_size);
RC4(&rc4_key, (size_t)fin.gcount(),(unsigned char *)in_data, (unsigned char *)out_data);
fout.write(out_data, fin.gcount());
};
fout.close();
fin.close();
RELESE_ARRAY(in_data);
RELESE_ARRAY(out_data);
return 0;
}
// 测试使用rc4解密文件算法的例子
int TestRc4DecryptFile(std::string in_file_path, std::string out_file_path,
const char *rc4_dencrypt_key, int encrypt_chunk_size = 16)
{
ifstream fin(in_file_path.c_str(), ios::binary);
ofstream fout(out_file_path, ios::binary);
if(!fin)
{
cout << "Can not open fin file." << endl;
return 1;
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
1715798051200)]
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!