1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- // PassWord.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "RandomKey.h"
- #include "PassWord.h"
- // CPassWord 对话框
- IMPLEMENT_DYNAMIC(CPassWord, CDialog)
- CPassWord::CPassWord(CWnd* pParent /*=NULL*/)
- : CDialog(CPassWord::IDD, pParent)
- , edit1(_T(""))
- , edit2(_T(""))
- , edit3(_T(""))
- {
- }
- CPassWord::~CPassWord()
- {
- }
- void CPassWord::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, IDC_EDIT1, edit1);
- DDX_Text(pDX, IDC_EDIT2, edit2);
- DDX_Text(pDX, IDC_EDIT3, edit3);
- }
- BEGIN_MESSAGE_MAP(CPassWord, CDialog)
- ON_BN_CLICKED(IDOK, &CPassWord::OnBnClickedOk)
- END_MESSAGE_MAP()
- // CPassWord 消息处理程序
- void CPassWord::OnBnClickedOk()
- {
- UpdateData(TRUE);
- CString szText;
- CStdioFile sFile( "./code.txt", CStdioFile::modeRead);
- sFile.ReadString(szText);
- sFile.Close();
- szText = Dectypt(szText);
- if (edit1 != szText)
- {
- MessageBox(" 密码错误! ");
- return;
- }
- if (edit2 != "" && edit2 == edit3)
- {
- FILE* pFile = fopen("./code.txt","w+");
- if (pFile)
- {
- CString szRet = Encrypt(edit2);
- fwrite(szRet,sizeof(char),szRet.GetLength(),pFile);
- fclose(pFile);
- MessageBox(" 修改密码成功 ");
- OnCancel();
- }
- }
- else
- {
- if (edit2 == "")
- {
- MessageBox(" 请输入新密码! ");
- }
- else
- {
- MessageBox(" 新密码输入不一致! ");
- }
- }
- }
|