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

📄 rsapropertypage.cpp

📁 RSA加密
💻 CPP
字号:
// RSAPropertyPage.cpp : implementation file
//

#include "stdafx.h"
#include "cryptology.h"
#include "RSAPropertyPage.h"


#include "KeyDlg.h"
#include "DecryptKeyDlg.h"

#include "RsaA.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRSAPropertyPage property page

IMPLEMENT_DYNCREATE(CRSAPropertyPage, CPropertyPage)

CRSAPropertyPage::CRSAPropertyPage() : CPropertyPage(CRSAPropertyPage::IDD)
{
	//{{AFX_DATA_INIT(CRSAPropertyPage)
	m_strDecryptString = _T("");
	m_strEncryptString = _T("");
	m_strPublicKey = _T("");
	m_strPrivateKey = _T("");
	m_strR = _T("");
	m_strSourceString = _T("");
	//}}AFX_DATA_INIT
}

CRSAPropertyPage::~CRSAPropertyPage()
{
}

void CRSAPropertyPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CRSAPropertyPage)
	DDX_Text(pDX, IDC_DECRYPTSTRING, m_strDecryptString);
	DDX_Text(pDX, IDC_ENCRYPTSTRING, m_strEncryptString);
	DDX_Text(pDX, IDC_PRIVATEKEY, m_strPublicKey);
	DDX_Text(pDX, IDC_PUBLICKEY, m_strPrivateKey);
	DDX_Text(pDX, IDC_R, m_strR);
	DDX_Text(pDX, IDC_SOURCESTRING, m_strSourceString);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CRSAPropertyPage, CPropertyPage)
	//{{AFX_MSG_MAP(CRSAPropertyPage)
	ON_BN_CLICKED(IDC_GENERATEKEY, OnGeneratekey)
	ON_BN_CLICKED(IDC_ENCRYPT, OnEncrypt)
	ON_BN_CLICKED(IDC_DECRYPT, OnDecrypt)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRSAPropertyPage message handlers

void CRSAPropertyPage::OnGeneratekey() 
{
	CRsaA rsa;
	rsa.GenKeys(m_strPublicKey,m_strPrivateKey,m_strR);
	UpdateData(FALSE);		
}

void CRSAPropertyPage::OnEncrypt() 
{
 UpdateData();
	KeyDlg dlg;  
	dlg.DoModal();
	m_strInputPublicKey=dlg.m_strInputEncryptKey;
	m_strInputR=dlg.m_strModeR;
	CRsaA rsa;	
	//下面的语句中需要进一步细化m_strR,以便可以直接调用加密函数
	rsa.RsaEncrypt(m_strSourceString,m_strInputPublicKey,m_strInputR,m_strEncryptStringArray);

	//处理加密后的字符串
	int index=0;
	CString strTempEncrypt;
	index=m_strEncryptStringArray.GetSize();
	for(int i=0;i<index;i++)
	{
		strTempEncrypt=m_strEncryptStringArray.GetAt(i);
	}
	m_strEncryptString=strTempEncrypt;

	UpdateData(false);		
}

void CRSAPropertyPage::OnDecrypt() 
{
    DecryptKeyDlg dlg;
	dlg.DoModal();
	m_strInputPrivateKey=dlg.m_strInputDecryptKey;
	m_strInputModeR1=dlg.m_strInputModeR1;
	CRsaA rsa;
	UpdateData();
	m_strDecryptString=rsa.RsaDecrypt(m_strEncryptStringArray,m_strInputPrivateKey,m_strInputModeR1);
	UpdateData(false);		
}

⌨️ 快捷键说明

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