void CRegisterDlg::OnOK() 
{
	CMD5 crypt;
	CString strTemp;

	UpdateData();

	m_strName.TrimLeft();
	m_strName.TrimRight();
	m_strKey.TrimLeft();
	m_strKey.TrimRight();
	strTemp = m_strName.Left(32);
	strTemp += MD5_HASH_KEY;

	crypt.setPlainText(strTemp);
	if (!m_strKey.Compare(crypt.getMD5Digest()))
	{
		CWinApp* pApp = AfxGetApp();

		UpdateData();

		pApp->WriteProfileString("Options", "Name", m_strName);
		pApp->WriteProfileString("Options", "Key", m_strKey);

		MessageBox("Registration key accepted!  Thank you for registering.", "Success");
	}
	else
	{
		MessageBox("Invalid registration key.  Please try again.", "Error");
		return;
	}
	
	CDialog::OnOK();
}
Exemple #2
0
bool CMD5::operator==(const CMD5& rhs)
{
    if (!isDigestValid() || !rhs.isDigestValid())
    {
        return false;
    }
    
    const char* rhsDigest = rhs.getMD5Digest();
    int result = strncmp(m_digestString, rhsDigest , 33);
    return (result == 0);
}