资源简介
AES_allmode.rar
代码片段和文件信息
// aestest2.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include
#include // StreamTransformationFilter
#include // CFB_Mode
#include // std:cerr
#include // std::stringstream
#include
using namespace std;
using namespace CryptoPP;
#pragma comment( lib “cryptlib.lib“ )
std::string ECB_AESEncryptStr(std::string sKey const char *plainText)
{
std::string outstr;
//填key
SecByteBlock key(AES::MAX_KEYLENGTH);
memset(key0x30key.size() );
sKey.size()<=AES::MAX_KEYLENGTH?memcpy(keysKey.c_str()sKey.size()):memcpy(keysKey.c_str()AES::MAX_KEYLENGTH);
AES::Encryption aesEncryption((byte *)key AES::MAX_KEYLENGTH);
ECB_Mode_ExternalCipher::Encryption ecbEncryption(aesEncryption);
StreamTransformationFilter ecbEncryptor(ecbEncryption new HexEncoder(new StringSink(outstr)));
ecbEncryptor.Put((byte *)plainText strlen(plainText));
ecbEncryptor.MessageEnd();
return outstr;
}
std::string ECB_AESDecryptStr(std::string sKey const char *cipherText)
{
std::string outstr;
//填key
SecByteBlock key(AES::MAX_KEYLENGTH);
memset(key0x30key.size() );
sKey.size()<=AES::MAX_KEYLENGTH?memcpy(keysKey.c_str()sKey.size()):memcpy(keysKey.c_str()AES::MAX_KEYLENGTH);
ECB_Mode::Decryption ecbDecryption((byte *)key AES::MAX_KEYLENGTH);
HexDecoder decryptor(new StreamTransformationFilter(ecbDecryption new StringSink(outstr)));
decryptor.Put((byte *)cipherText strlen(cipherText));
decryptor.MessageEnd();
return outstr;
}
std::string CBC_AESEncryptStr(std::string sKey std::string sIV const char *plainText)
{
std::string outstr;
//填key
SecByteBlock key(AES::MAX_KEYLENGTH);
memset(key0x30key.size() );
sKey.size()<=AES::MAX_KEYLENGTH?memcpy(keysKey.c_str()sKey.size()):memcpy(keysKey.c_str()AES::MAX_KEYLENGTH);
//填iv
byte iv[AES::BLOCKSIZE];
memset(iv0x30AES::BLOCKSIZE);
sIV.size()<=AES::BLOCKSIZE?memcpy(ivsIV.c_str()sIV.size()):memcpy(ivsIV.c_str()AES::BLOCKSIZE);
AES::Encryption aesEncryption((byte *)key AES::MAX_KEYLENGTH);
CBC_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption iv);
StreamTransformationFilter cbcEncryptor(cbcEncryption new HexEncoder(new StringSink(outstr)));
cbcEncryptor.Put((byte *)plainText strlen(plainText));
cbcEncryptor.MessageEnd();
return outstr;
}
std::string CBC_AESDecryptStr(std::string sKey std::string sIV const char *cipherText)
{
std::string outstr;
//填key
SecByteBlock key(AES::MAX_KEYLENGTH);
memset(key0x30key.size() );
sKey.size()<=AES::MAX_KEY
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 14106 2013-03-31 20:25 aestest2\aestest2\aestest2.cpp
文件 4638 2013-03-29 21:57 aestest2\aestest2\aestest2.vcxproj
文件 1312 2013-03-29 21:49 aestest2\aestest2\aestest2.vcxproj.filters
文件 143 2013-03-29 21:49 aestest2\aestest2\aestest2.vcxproj.user
文件 1560 2013-03-29 21:49 aestest2\aestest2\ReadMe.txt
文件 213 2013-03-29 21:49 aestest2\aestest2\stdafx.cpp
文件 233 2013-03-29 21:49 aestest2\aestest2\stdafx.h
文件 236 2013-03-29 21:49 aestest2\aestest2\targetver.h
文件 891 2013-03-29 21:49 aestest2\aestest2.sln
..A..H. 11776 2013-03-31 20:25 aestest2\aestest2.suo
文件 1807360 2013-03-31 20:25 aestest2\Debug\aestest2.exe
目录 0 2013-03-31 20:26 aestest2\aestest2
目录 0 2013-03-31 20:26 aestest2\Debug
目录 0 2013-03-31 20:26 aestest2
----------- --------- ---------- ----- ----
1842468 14
- 上一篇:串口调试助手2.3
- 下一篇:《旅游公司综合信息管理系统》需求规格说明书
相关资源
- 65520765NS2example.rar
- DLX流水线实验报告.docx
- LINUX设备驱动开发详解带书签全套资料
-
shock_opman.xm
l - ImageProcess.dll
- CCS5中文包(对于有ccs5非中文的人员提
- 51单片机设计交通灯仿真C程序.rar
- 百度文库批量上传软件.pptx
- 西瓜3.xlsx
- 魔塔原生js版.zip
- code.txt
- Sim_EKB_Install_2017_12_24_TIA15.exe
- hz_zsy_1584430.zip
- fld1rr.rar
- 96ab9ef1f295eb0668db3e303b2310d0.rar
- tex2word破解版).rar
- (上).pdf
- glr7nu.rar
- 资料.rar
- VIDC20利用公网IP权限,开放内网的IP
- -大学IT网.doc
- 单片机实验考试程序-汇编.rar
-
li
nk.txt - ce49018c800ab7b9167db0d59e246901.rar
- PortFinder.rar
- jdk.txt
- 7x8x统一规则发布模块.rar
- test.htm
- c9cf03eff7255712a6ed328fe1408ae5.h
- hopchen_7959641.zip
评论
共有 条评论