⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rsatest.cpp

📁 RSA 1024位加密算法封装
💻 CPP
字号:
#include "stdafx.h"
#include "RSAWapper.h"
#include <winbase.h>
#define APPNAME    L"TESTCSP"


bool DoCrypto(BYTE byCryptoType, IN WCHAR * pszKeyFile, IN BYTE * pbyInput, IN BYTE byInputLen, OUT BYTE * pbyOutput, OUT BYTE *pbyOutputLen);
RSAWapper RSATest;
void TRACE(LPCTSTR szFormat, ...);
int _tmain(int argc, _TCHAR* argv[])
{
 RSATest.GenerateKeys();
 BYTE Input[30];
 BYTE Output[30];
 BYTE OutputLen;
 for(int i=0;i<30;i++)
 {
	 Input[i]=i;
 }
 DoCrypto(1,L"haha",Input,30,Output,&OutputLen);
 Output[29]=0;
TRACE(L"%s,%d",Output,OutputLen);
}
bool DoCrypto(BYTE byCryptoType, IN WCHAR * pszKeyFile, IN BYTE * pbyInput, IN BYTE byInputLen, OUT BYTE * pbyOutput, OUT BYTE *pbyOutputLen) 
{
 size_t iInputLen=(size_t)byInputLen;
 size_t iOutputLen;
 iOutputLen=iInputLen;
 RSATest.Encrypt(pbyInput,byInputLen,pbyOutput,iOutputLen);
 (*pbyOutputLen)=(BYTE)iOutputLen;
 return true;
}
void TRACE(LPCTSTR szFormat, ...)
{
#define MSG_HDR APPNAME L": "

	TCHAR szBuffer[128];

	// Build the message.
	_tcscpy(szBuffer, MSG_HDR);
	va_list pArgs; 
	va_start(pArgs, szFormat);
	wvsprintf(szBuffer + 9, szFormat, pArgs);
	va_end(pArgs);

	// Send the message string to the debugger as well.
	_tcscat(szBuffer, TEXT("\r\n"));
	OutputDebugString(szBuffer);  // Send to Debugger
	wprintf (szBuffer);           // and also send to console
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -