📄 xxmcmm.cpp
字号:
// xxmcmm.cpp : implementation file
//
#include "stdafx.h"
#include "xxgl.h"
#include "xxmcmm.h"
#include "process.h"
#include "strt.h"
#include "ext.h"
#include "func.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static int out_flag,cur_focus;
Cxxmcmm::Cxxmcmm(CWnd* pParent /*=NULL*/)
: CDialog(Cxxmcmm::IDD, pParent)
{
//{{AFX_DATA_INIT(Cxxmcmm)
m_mm = _T("");
m_xxmc = _T("");
//}}AFX_DATA_INIT
out_flag = cur_focus = 0;
}
void Cxxmcmm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cxxmcmm)
DDX_Text(pDX, IDC_mm, m_mm);
DDX_Text(pDX, IDC_xxmc, m_xxmc);
//}}AFX_DATA_MAP
CBitmap *bitmap;
CBitmap *bitmap1;
HBITMAP hbitmap;
HBITMAP hbitmap1;
bitmap = new CBitmap();
bitmap1 = new CBitmap();
bitmap->LoadBitmap(IDB_qr);
bitmap1->LoadBitmap(IDB_qx);
hbitmap = (*bitmap).operator HBITMAP();
hbitmap1 = (*bitmap1).operator HBITMAP();
CWnd *wn;
CWnd *wn1;
wn = GetDlgItem(IDOK);
wn1 = GetDlgItem(IDCANCEL);
WPARAM wParam;
LPARAM lParam;
wParam = (WPARAM) LOWORD(BS_LEFT | BS_BITMAP); // style
lParam = MAKELPARAM(TRUE, 0); // redraw flag
wn->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap);
wn1->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap1);
}
BEGIN_MESSAGE_MAP(Cxxmcmm, CDialog)
//{{AFX_MSG_MAP(Cxxmcmm)
ON_EN_SETFOCUS(IDC_mm, OnSetfocusmm)
ON_EN_SETFOCUS(IDC_xxmc, OnSetfocusxxmc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cxxmcmm message handlers
extern char code[500];
extern char code1[500];
extern char code2[500];
extern char code3[500];
extern char code4[500];
extern char code5[500];
extern char code6[500];
extern int tab[2000];
extern char process_flag[2000];
static char xiaoming[50];
int find_a_seat(int max);
int rand1();
extern int rand_base;
void Cxxmcmm::OnOK()
{
unsigned char buf[40];
unsigned char pass[40];
int l,i,c,j,k,flag;
unsigned char mask;
CWnd *wd_mm,*wd_xxmc,*wd_ok;
wd_mm = GetDlgItem(IDC_mm);
wd_xxmc = GetDlgItem(IDC_xxmc);
wd_ok = GetDlgItem(IDOK);
if (cur_focus == 1){
wd_mm->SetFocus();
cur_focus = 2;
return;
}
if (cur_focus == 2){
wd_ok->SetFocus();
cur_focus = 3;
return;
}
rand_base = 1000;
GetDlgItemText(IDC_xxmc,(char *)buf,50);
GetDlgItemText(IDC_mm,(char *)pass,50);
for (i=0;i<strlen((char *)pass);i++){
if ((pass[i] >= 'a')&&(pass[i] <= 'z'))
pass[i] += 'A' - 'a';
}
l = strlen((char *)buf);
for (i=0;i<l*8;i++){
c = buf[i/8];
mask = 1;
for (j=0;j<i%8;j++)
mask *= 2;
code[i] = c & mask;
if (code[i] != 0)
code[i] = 1;
}
for (i=0;i<1000;i++)
process_flag[i] = 0;
flag = 0;
j = 0;
while (flag == 0){
i = find_a_seat(l*8);
tab[j] = i;
process_flag[i] = 1;
j ++;
if (j == l*8)
flag = 1;
}
for (i=0;i<l*8;i++){
code6[i] = code[tab[i]];
}
for (i=0;i<l*8;i++)
code[i] = code6[i];
for (i=0;i<l*8;i++){
j = i + l%7;
if (j >= l*8)
j -= l*8;
code1[i] = code[j];
}
for (i=0;i<l*4;i++){
code2[i] = code1[2*i+1];
}
for (i=0;i<l*8;i++){
j = i + l%7;
if (j > l*8)
j -= l*8;
code3[i] = code[j];
}
for (i=0;i<l*4;i++){
code4[i] = code3[2*i];
}
for (i=0;i<l*4;i++)
code5[i] = code2[i] ^ code4[i];
/*
k = 0;
for (i=0;i<l;i++){
c = code5[i*4]*8 + code5[i*4+1]*4 + + code5[i*4+2]*2 + + code5[i*4+3];
if (c < 10)
c += '0';
else
c += 'A' - 10;
pass[k++] = c;
}
pass[k] = 0;
*/
for (i=0;i<l;i++){
c = pass[i];
if (c >= 'A')
c = c - 'A' + 10;
else
c -= '0';
code5[4*i] = c / 8;
c = c % 8;
code5[4*i+1] = c / 4;
c = c % 4;
code5[4*i+2] = c / 2;
code5[4*i+3] = c % 2;
}
for (i=0;i<l*4;i++)
code2[i] = code5[i] ^ code4[i];
for (i=0;i<l*4;i++){
code1[2*i+1] = code2[i];
}
for (i=0;i<l*8;i++){
j = i - l%7;
if (j < 0)
j = j + l*8;
code[i] = code1[j];
}
for (i=0;i<l*8;i++){
code6[tab[i]] = code[i];
}
for (i=0;i<l*8;i++)
code[i] = code6[i];
for (i=0;i<l;i++){
buf[i] = code[i*8] + code[i*8+1]*2 + code[i*8+2]*4 + code[i*8+3]*8
+ code[i*8+4]*16 + code[i*8+5]*32 + code[i*8+6]*64 + code[i*8+7]*128;
}
strcpy(xiaoming,(char *)buf);
GetDlgItemText(IDC_xxmc,(char *)buf,50);
if (strcmp(xiaoming,(char *)buf) != 0){
MessageBox("学校名称或密码错误.","",MB_OK);
exit(-1);
}
FILE *fpe;
fpe = fopen("c:\\xxsbgl\\mima.txt","w");
fprintf(fpe,"%s\n%s\n",buf,pass);
fclose(fpe);
CDialog::OnOK();
}
void Cxxmcmm::OnCancel()
{
// TODO: Add extra cleanup here
exit(-1);
CDialog::OnCancel();
}
void Cxxmcmm::OnSetfocusmm()
{
CWnd *wnd;
wnd = GetDlgItem(IDC_mm);
switch_to_english_mode(wnd);
cur_focus = 2;
}
void Cxxmcmm::OnSetfocusxxmc()
{
CWnd *wnd;
wnd = GetDlgItem(IDC_xxmc);
switch_to_chinese_mode(wnd);
cur_focus = 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -