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

📄 aesdemoviewkey.cpp

📁 cRijndael - Advanced Encryption Standard (AES)
💻 CPP
字号:
// AESDemoViewKey.cpp : implementation file
//

#include "stdafx.h"
#include "AESDemo.h"
#include "AESDemoViewKey.h"


// CAESDemoViewKey dialog

IMPLEMENT_DYNAMIC(CAESDemoViewKey, CDialog)
CAESDemoViewKey::CAESDemoViewKey(CWnd* pParent /*=NULL*/)
	: CDialog(CAESDemoViewKey::IDD, pParent)
	, m_strKey(_T(""))
{
	m_pParent = pParent;
}

CAESDemoViewKey::~CAESDemoViewKey()
{
}

BOOL CAESDemoViewKey::OnInitDialog()
{
	int i, j;
	CDialog::OnInitDialog();
	
	UpdateData();

	// Get the encryption and decryption keys
	CString strEnc, strDec;
	if (m_pParent)
	{
		// Set the key string
		m_strKey = "";
		for (i = 0; i < ((CAESDemoDlg *)m_pParent)->m_iKeySize; i++)
		{
			m_strKey.AppendFormat("%0.2X ", ((CAESDemoDlg *)m_pParent)->m_piKey[i]);
			
			// Add a little formating
			if(16 < ((CAESDemoDlg *)m_pParent)->m_iKeySize && 
				i == (((CAESDemoDlg *)m_pParent)->m_iKeySize / 2) - 1)
				m_strKey += "\n";
		}

		// Get the encryption and decryption keys
		for (i = 0; i < (((CAESDemoDlg *)m_pParent)->m_iRounds + 1); i++)
		{
			strEnc.Format("%2d - ", i);
			strDec.Format("%2d - ", i);
			for (j = 0; j < CAES::BC; j++)
			{
				strEnc.AppendFormat("%0.8X  ", 
					((CAESDemoDlg *)m_pParent)->m_iKeyEnc[i][j]);
				strDec.AppendFormat("%0.8X  ", 
					((CAESDemoDlg *)m_pParent)->m_iKeyDec[i][j]);
			}
			// Add strings to list boxes
			m_kEncKey.AddString(strEnc);
			m_kDecKey.AddString(strDec);
		}
	}

	UpdateData(FALSE);
	return TRUE;
}


void CAESDemoViewKey::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_DECKEY, m_kDecKey);
	DDX_Control(pDX, IDC_ENCKEY, m_kEncKey);
	DDX_Text(pDX, IDC_KEY, m_strKey);
}


BEGIN_MESSAGE_MAP(CAESDemoViewKey, CDialog)
END_MESSAGE_MAP()


// CAESDemoViewKey message handlers

⌨️ 快捷键说明

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