資源簡介
Visual c++調試編譯通過
調用函數:
加密:void To3DES(const char *data,const char *key,char *enDes)
解密:void To3String(const char *dataHexString,char *key,char *enDes)
調用函數:
加密:void To3DES(const char *data,const char *key,char *enDes)
解密:void To3String(const char *dataHexString,char *key,char *enDes)
代碼片段和文件信息
//?DESDLL.cpp?:?Defines?the?entry?point?for?the?DLL?application.
//
#include?“stdafx.h“
#include?“DESDLL.h“
#include?“DES.h“
BOOL?APIENTRY?DllMain(?HANDLE?hModule?
???????????????????????DWORD??ul_reason_for_call?
???????????????????????LPVOID?lpReserved
?)
{
????switch?(ul_reason_for_call)
{
case?DLL_PROCESS_ATTACH:
case?DLL_THREAD_ATTACH:
case?DLL_THREAD_DETACH:
case?DLL_PROCESS_DETACH:
break;
????}
????return?TRUE;
}
//?This?is?an?example?of?an?exported?variable
DESDLL_API?int?nDESDLL=0;
//?This?is?an?example?of?an?exported?function.
DESDLL_API?int?fnDESDLL(void)
{
return?42;
}
//?This?is?the?constructor?of?a?class?that?has?been?exported.
//?see?DESDLL.h?for?the?class?definition
CDESDLL::CDESDLL()
{?
return;?
}
////////////////////////
/////////////////////////////////////////////////
//?字符串3DES加密,輸出16進制字符串
extern?“C“?_declspec(dllexport)?void??To3DES(const?char?*dataconst?char?*keychar?*enDes)
{
// USES_CONVERSION;
// std::string?en3DES;
if(strlen(key)?!=?24)
{
//CHAR?sAuthor[256];
//int?nCount?=LoadString(NULLIDS_AUTHORsAuthor256);
// key?=?::from3DESHex(sAuthor“2C956CC9158F7CCF1238A9C6A5EB3B2CD05B32B5CEF5A4B2CED10DCB2382A42E“);?//
key?=?“123456123456123456123456“;
}
//????????unsigned?char?key11[]?=?{‘1‘‘2‘‘3‘‘4‘‘5‘‘6‘‘1‘‘2‘};
//????????unsigned?char?key22[]?=?{‘3‘‘4‘‘5‘‘6‘‘1‘‘2‘‘3‘‘4‘};
//????????unsigned?char?key33[]?=?{‘5‘‘6‘‘1‘‘2‘‘3‘‘4‘‘5‘‘6‘};?//如果只需要兩組密鑰,則本組密鑰可以和密鑰1一樣。
unsigned?char?*?Key?=?(unsigned?char?*)key;
//qDebug()<“Key:“?< int?stringSize?=?strlen(data);
int?desDataSize;
//?計算所需存儲大小
if(stringSize?&?0x00000007)
stringSize?=?stringSize+8-stringSize%8;
else
stringSize?=?stringSize+8;
unsigned?char?en_data[102400];
memset(en_data0102400);
//????????stringSize?=?data.toAscii().size();
//?補位
RunPad(PAD_PKCS_7datastrlen(data)(char?*)en_data&desDataSize);
if(desDataSize?==?0)
desDataSize?=?stringSize;
//????????memcpy(en_datadata.toAscii().constData()stringSize);
//????????char?*?p?=?(char?*?)en_data;
//????????*(p+data.toAscii().size())=‘A‘;
//????????memset(en_data+stringSize0x001);
unsigned?char?en_out_put[10240];
unsigned?char?de_out_put[10240];
char?HexEn_out_put[10240];
memset(en_out_put010240);
memset(de_out_put010240);
memset(HexEn_out_put010240);
//3DES?加密
{
//std::string?des3String;
//?加密
int?result?=?Run3Des(ENCRYPTECB(const?char*)en_datadesDataSize*2(const?char*)Keystrlen((const?char?*)Key)(char?*)en_out_put?stringSize*2NULL);
//des3String=std::string((A2W((const?char*)en_out_put));
//qDebug()<<“Run3DesENCRYPT?State:“< //?十進制Char串轉十六進制串
CharStr2HexStr((unsigned?char?const*)en_out_putHexEn_out_putdesDataSize);
memcpy(enDesHexEn_out_putsizeof(HexEn_out_put));
// en3DES?=?std::string(HexEn_out_put);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????237628??2014-07-08?12:38??DESDLL\debug\DESDLL.dll
?????文件???????2914??2014-07-08?12:37??DESDLL\debug\DESDLL.lib
?????文件??????32503??2014-07-08?12:36??DESDLL\DES.CPP
?????文件???????4532??2014-07-08?12:36??DESDLL\DES.H
?????文件???????5054??2014-07-08?12:38??DESDLL\DESDLL.cpp
?????文件???????4472??2014-07-08?12:40??DESDLL\DESDLL.dsp
?????文件????????518??2014-07-08?12:40??DESDLL\DESDLL.dsw
?????文件????????826??2014-07-08?12:35??DESDLL\DESDLL.h
?????文件??????41984??2014-07-08?12:40??DESDLL\DESDLL.ncb
?????文件??????48640??2014-07-08?12:40??DESDLL\DESDLL.opt
?????文件????????734??2014-07-08?12:38??DESDLL\DESDLL.plg
?????文件???????1247??2014-07-08?12:35??DESDLL\ReadMe.txt
?????文件????????293??2014-07-08?12:35??DESDLL\StdAfx.cpp
?????文件????????802??2014-07-08?12:35??DESDLL\StdAfx.h
?????目錄??????????0??2014-07-08?12:41??DESDLL\debug
?????目錄??????????0??2014-07-08?12:41??DESDLL
-----------?---------??----------?-----??----
???????????????382147????????????????????16
- 上一篇:flash 倒計時器
- 下一篇:報文模擬仿真測試工具2.0
評論
共有 條評論