www.pudn.com > Rijndael算法VC使用实例.rar > RijndView.cpp
// RijndView.cpp : implementation of the CRijndView class
//
#include "stdafx.h"
#include "Rijnd.h"
#include "RijndDoc.h"
#include "RijndView.h"
#include "rijndael.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//定义
rijndael rij;
/////////////////////////////////////////////////////////////////////////////
// CRijndView
IMPLEMENT_DYNCREATE(CRijndView, CFormView)
BEGIN_MESSAGE_MAP(CRijndView, CFormView)
//{{AFX_MSG_MAP(CRijndView)
ON_BN_CLICKED(IDC_ENCRYPTION, OnEncryption)
ON_BN_CLICKED(IDC_UNCRYPTION, OnUncryption)
ON_BN_CLICKED(IDC_ENCRYPTION_SELECT, OnEncryptionSelect)
ON_BN_CLICKED(IDC_UNCRYPTION_SELECT, OnUncryptionSelect)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRijndView construction/destruction
CRijndView::CRijndView()
: CFormView(CRijndView::IDD)
{
//{{AFX_DATA_INIT(CRijndView)
m_miyao = _T("shufuxiashufuxiashufuxiashufuxia");
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CRijndView::~CRijndView()
{
}
void CRijndView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRijndView)
DDX_Text(pDX, IDC_KEY, m_miyao);
//}}AFX_DATA_MAP
}
BOOL CRijndView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CRijndView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// CRijndView printing
BOOL CRijndView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CRijndView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CRijndView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CRijndView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CRijndView diagnostics
#ifdef _DEBUG
void CRijndView::AssertValid() const
{
CFormView::AssertValid();
}
void CRijndView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CRijndDoc* CRijndView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRijndDoc)));
return (CRijndDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CRijndView message handlers
void CRijndView::OnEncryption()
{
// TODO: Add your control notification handler code here
k_bit=(unsigned char*)m_miyao.GetBuffer(8);
m_miyao.ReleaseBuffer();
unsigned char *e_bit;
e_bit=new unsigned char [length];
BeginWaitCursor();
{
rij.set_key(k_bit,256);
for(int j=0;j