编完了计算器的,觉得mfc什么的入门也不是难的嘛,虽然难度比java的界面确实要难,
但是也没有难到很过分的地步。
就贴一下核心代码意思意思就行了。
#ifndef MD5_H
#define MD5_H
#include <string>
#include <fstream>
/* Type define */
typedef unsigned char byte;
typedef unsigned int uint32;
using std::string;
using std::ifstream;
/* MD5 declaration. */
class MD5 {
public:
MD5();
MD5(const void* input, size_t length);
MD5(const string& str);
MD5(ifstream& in);
void update(const void* input, size_t length);
void update(const string& str);
void update(ifstream& in);
const byte* digest();
string toString();
void reset();
private:
void update(const byte* input, size_t length);
void final();
void transform(const byte block[64]);
void encode(const uint32* input, byte* output, size_t length);
void decode(const byte* input, uint32* output, size_t length);
string bytesToHexString(const byte* input, size_t length);
/* class uncopyable */
MD5(const MD5&);
MD5& operator=(const MD5&);
private:
uint32 _state[4]; /* state (ABCD) */
uint32 _count[2]; /* number of bits, modulo 2^64 (low-order word first) */
byte _buffer[64]; /* input buffer */
byte _digest[16]; /* message digest */
bool _finished; /* calculate finished ? */
static const byte PADDING[64]; /* padding for calculate */
static const char HEX[16];
enum { BUFFER_SIZE = 1024 };
};
#endif /*MD5_H*/
// md5_3Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "md5_3.h"
#include "md5_3Dlg.h"
#include "md5.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{
{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{
{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{
{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{
{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{
{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{
{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/
// CMd5_3Dlg dialog
CMd5_3Dlg::CMd5_3Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CMd5_3Dlg::IDD, pParent)
{
//{
{AFX_DATA_INIT(CMd5_3Dlg)
m_string = _T("");
m_num = 0;
m_result = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMd5_3Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{
{AFX_DATA_MAP(CMd5_3Dlg)
DDX_Control(pDX, IDC_EDIT3, m_CResult);
DDX_Text(pDX, IDC_EDIT1, m_string);
DDX_Text(pDX, IDC_EDIT2, m_num);
DDX_Text(pDX, IDC_EDIT3, m_result);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMd5_3Dlg, CDialog)
//{
{AFX_MSG_MAP(CMd5_3Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit3)
ON_EN_SETFOCUS(IDC_EDIT1, OnSetfocusEdit1)
ON_EN_MAXTEXT(IDC_EDIT2, OnMaxtextEdit2)
ON_EN_SETFOCUS(IDC_EDIT2, OnSetfocusEdit2)
ON