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

📄 sha12dlldlg.cpp

📁 通过SHA1
💻 CPP
字号:
// SHA12dllDlg.cpp : implementation file
//
#include "StdAfx.h"
#include "stdafx.h"
#include "SHA12dll.h"
#include "SHA12dllDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


#include "math.h"
#define SHA1_LITTLE_ENDIAN


#include ".\dllSHA12\sha.h"

#pragma comment(lib,"dllSHA12.lib")
/////////////////////////////////////////////////////////////////////////////
// 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()

/////////////////////////////////////////////////////////////////////////////
// CSHA12dllDlg dialog

CSHA12dllDlg::CSHA12dllDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSHA12dllDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSHA12dllDlg)
	m_Input_HEX = _T("");
	m_Input_CS = _T("");
	m_Output_CS = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CSHA12dllDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSHA12dllDlg)
	DDX_Text(pDX, IDC_EDIT2, m_Input_HEX);
	DDX_Text(pDX, IDC_EDIT1, m_Input_CS);
	DDX_Text(pDX, IDC_EDIT3, m_Output_CS);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSHA12dllDlg, CDialog)
	//{{AFX_MSG_MAP(CSHA12dllDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnHashCS)
	ON_BN_CLICKED(IDC_BUTTON2, OnHashHex)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSHA12dllDlg message handlers

BOOL CSHA12dllDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSHA12dllDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CSHA12dllDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSHA12dllDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
CString CSHA12dllDlg::Int10_To_Bitstr(unsigned pInt){
	CString str1="";
	unsigned sang=pInt,remain;
	char c1;
	while (sang>1)
	{
		remain=sang%2;
		sang=sang/2;
		c1=remain+48;
		str1=str1+c1;
	}
	c1=sang+48;
	str1=str1+c1;
	str1.MakeReverse();
	return str1;
}

CString CSHA12dllDlg::Int10_To_Hexstr(unsigned pInt,int ws){
	CString rst="",cs1,cs2;
	int i=0,nLen,rm;
	cs1=Int10_To_Bitstr(pInt);
	nLen=cs1.GetLength();
	rm=nLen%4;
	if(rm==0)rm=4;
	if(nLen<4)rm=nLen;
	while (i<nLen)
	{
		cs2=cs1.Mid(i,rm);
		rst=rst+HexArr[Binstr_To_Int10(cs2)];
		i+=rm;
		rm=4;
	}
	if (ws>2)
	{
		nLen=rst.GetLength();
		if(nLen<ws)
		{
			for(i=1;i<=(ws-nLen);i++)
				rst="0"+rst;
		}
	}
	return rst;
}
int CSHA12dllDlg:: Binstr_To_Int10(CString cs){
	int i,nLen=cs.GetLength();
	unsigned rst=0;
	for (i=0;i<nLen;i++)
	{
		rst=rst+(cs[i]-48)*(unsigned)pow(2,nLen-i-1);
	}
	return rst;
}
//typedef
void CSHA12dllDlg::OnHashCS() 
{
	// TODO: Add your control notification handler code here
		UpdateData(TRUE);
	int c;
	CString cs1,cs2;
	for (int i=0;i<m_Input_CS.GetLength();i++)
	{
		c=m_Input_CS[i];
		//MessageBox(m_csInput);
		//MessageBox();
		if (c<0)
		{
			c+=256;
		}
		
		cs2=cs2+Int10_To_Hexstr(c,2);
	}
	m_Input_HEX=cs2;
	//m_Edit_HexMw.SetWindowText(cs2);
	//MessageBox(cs2);
	if (cs2.GetLength()>0)
	{
		CSHA1 hasher;
		hasher.Update((UINT_8 *)(cs2.GetBuffer(256)),cs2.GetLength());
		hasher.Final();
		char szInforChar[64];
		memset(szInforChar,0,sizeof(char)*64);
		hasher.ReportHash(szInforChar);
		m_Output_CS=szInforChar;

	}
	UpdateData(FALSE);
}

void CSHA12dllDlg::OnHashHex() 
{
	// TODO: Add your control notification handler code here
		UpdateData(TRUE);
	CString cs2;

	cs2=m_Input_HEX;
	//MessageBox(cs2);
	if (cs2.GetLength()>0)
	{
		CSHA1 hasher;
		//HINSTANCE hdll;
		//lpUpdataFun 
		hasher.Update((UINT_8 *)(cs2.GetBuffer(256)),cs2.GetLength());
		hasher.Final();
		char szInforChar[64];
		memset(szInforChar,0,sizeof(char)*64);
		hasher.ReportHash(szInforChar);
		m_Output_CS=szInforChar;

	}
	UpdateData(FALSE);
}

void CSHA12dllDlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

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