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

📄 md5checksumtestdlg.cpp

📁 MD5 加 密的V i s u a l C + + S o u r c e C o d e .
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			 Tests function CMD5Checksum::GetMD5(CFile& File)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest04()
{
	//test passing CFile file.
	CString strFile = m_strTestDataPath + CString("\\abc.txt");
	CFile File(
		strFile,
		CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary
	);

	bool bResult = CMD5Checksum::GetMD5(File) == "900150983cd24fb0d6963f7d28e17f72";
	File.Close();

	return bResult;
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest05
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for the string "abc"
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72
			 Tests function CMD5Checksum::GetMD5(BYTE* pBuf, UINT nLength)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest05()
{
	CString strABC("abc");
	return CMD5Checksum::GetMD5( 
				(BYTE*)(const char*)strABC,strABC.GetLength()
		   ) == "900150983cd24fb0d6963f7d28e17f72";
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest06
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a file containing "abc"
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72
			 Tests the function CMD5Checksum::GetMD5(const CString& strFilePath)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest06()
{
	CString strFile = m_strTestDataPath + CString("\\abc.txt");
	return CMD5Checksum::GetMD5( strFile ) == "900150983cd24fb0d6963f7d28e17f72";
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest07
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for an empty file
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5("") = d41d8cd98f00b204e9800998ecf8427e
			 Tests the function CMD5Checksum::GetMD5(const CString& strFilePath)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest07()
{
	CString strFile = m_strTestDataPath + CString("\\Empty.txt");
	return CMD5Checksum::GetMD5( strFile ) == "d41d8cd98f00b204e9800998ecf8427e";
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest08
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for an empty file
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5("") = d41d8cd98f00b204e9800998ecf8427e
			 Tests function CMD5Checksum::GetMD5(CFile& File)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest08()
{
	//test passing CFile file.
	CString strFile = m_strTestDataPath + CString("\\Empty.txt");
	CFile File(
		strFile,
		CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary
	);

	bool bResult = CMD5Checksum::GetMD5(File) == "d41d8cd98f00b204e9800998ecf8427e";
	File.Close();

	return bResult;
}

/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest09
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for an empty buffer of zero size
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5("") = d41d8cd98f00b204e9800998ecf8427e
			 Tests function CMD5Checksum::GetMD5(BYTE* pBuf, UINT nLength)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest09()
{
	CString strEmpty("");
	return CMD5Checksum::GetMD5( 
			(BYTE*)(const char*)strEmpty, 0
	   ) == "d41d8cd98f00b204e9800998ecf8427e";

}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest10
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a file containing "a"
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5("a") = 0cc175b9c0f1b6a831c399e269772661
			 Tests the function CMD5Checksum::GetMD5(const CString& strFilePath)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest10()
{
	CString strFile = m_strTestDataPath + CString("\\a.txt");
	return CMD5Checksum::GetMD5( strFile ) == "0cc175b9c0f1b6a831c399e269772661";
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest11
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a file containing "a"
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5("a") = 0cc175b9c0f1b6a831c399e269772661
			 Tests function CMD5Checksum::GetMD5(CFile& File)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest11()
{
	//test passing CFile file.
	CString strFile = m_strTestDataPath + CString("\\a.txt");
	CFile File(
		strFile,
		CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary
	);

	bool bResult = CMD5Checksum::GetMD5(File) == "0cc175b9c0f1b6a831c399e269772661";
	File.Close();

	return bResult;
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest12
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for the string "a"
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5("a") = 0cc175b9c0f1b6a831c399e269772661
			 Tests function CMD5Checksum::GetMD5(BYTE* pBuf, UINT nLength)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest12()
{
	CString stra("a");
	return CMD5Checksum::GetMD5( 
				(BYTE*)(const char*)stra, 1
		   ) == "0cc175b9c0f1b6a831c399e269772661";
}



/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest13
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a file containing the alphabet
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b
			 Tests function CMD5Checksum::GetMD5(CFile& File)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest13()
{
	CString strFile = m_strTestDataPath + CString("\\Alpha.txt");
	//test passing CFile file.
	CFile File(
		strFile,
		CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary
	);

	bool bResult = CMD5Checksum::GetMD5(File) == "c3fcd3d76192e4007dfb496cca67e13b";
	File.Close();

	return bResult;
}



/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest14
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a file containing the alphabet
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b
			 Tests the function CMD5Checksum::GetMD5(const CString& strFilePath)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest14()
{
	CString strFile = m_strTestDataPath + CString("\\Alpha.txt");
	return CMD5Checksum::GetMD5( strFile ) == "c3fcd3d76192e4007dfb496cca67e13b";
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest15
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a string containing the alphabet
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b
			 Tests function CMD5Checksum::GetMD5(BYTE* pBuf, UINT nLength)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest15()
{
	CString strAlpha("abcdefghijklmnopqrstuvwxyz");
	return CMD5Checksum::GetMD5( 
				(BYTE*)(const char*)strAlpha, 26
		   ) == "c3fcd3d76192e4007dfb496cca67e13b";
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest15a
DETAILS:	 protected
DESCRIPTION: Checks the SelfTest15 calculation for a corrupted alphabet
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("abcdefghijklMnopqrstuvwxyz") != c3fcd3d76192e4007dfb496cca67e13b
			 Tests function CMD5Checksum::GetMD5(BYTE* pBuf, UINT nLength)
			 Checks that if one of the letters in the alphabet (in this case 'm') is
			 changed to uppercase, then a different checksum to that calculated in 
			 SelfTest15 is obtained.
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest15a()
{
	CString strAlpha("abcdefghijklMnopqrstuvwxyz");
	return CMD5Checksum::GetMD5( 
				(BYTE*)(const char*)strAlpha, 26
		   ) != "c3fcd3d76192e4007dfb496cca67e13b";
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest16
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a file containing the alphabet and numbers
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
			 d174ab98d277d9f5a5611c2c9f419d9f
			 Tests function CMD5Checksum::GetMD5(CFile& File)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest16()
{
	CString strFile = m_strTestDataPath + CString("\\AlphaNumeric.txt");
	//test passing CFile file.
	CFile File(
		strFile,
		CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary
	);

	bool bResult = CMD5Checksum::GetMD5(File) == "d174ab98d277d9f5a5611c2c9f419d9f";
	File.Close();

	return bResult;
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest17
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a file containing the alphabet and numbers
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
			 d174ab98d277d9f5a5611c2c9f419d9f
			 Tests the function CMD5Checksum::GetMD5(const CString& strFilePath)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest17()
{
	CString strFile = m_strTestDataPath + CString("\\AlphaNumeric.txt");
	return CMD5Checksum::GetMD5( strFile ) == "d174ab98d277d9f5a5611c2c9f419d9f";
}


/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest18
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a string containing the alphabet and numbers
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none
NOTES:		 MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
			 d174ab98d277d9f5a5611c2c9f419d9f
			 Tests function CMD5Checksum::GetMD5(BYTE* pBuf, UINT nLength)
*****************************************************************************************/
bool CMD5ChecksumTestDlg::SelfTest18()
{
	CString strAlphaNumeric("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
	return CMD5Checksum::GetMD5( 
				(BYTE*)(const char*)strAlphaNumeric, strAlphaNumeric.GetLength()
		   ) == "d174ab98d277d9f5a5611c2c9f419d9f";
}

/*****************************************************************************************
FUNCTION:	 CMD5ChecksumTestDlg::SelfTest18a
DETAILS:	 protected
DESCRIPTION: Checks the MD5 checksum calculation for a corrupted SelfTest18 string 
RETURNS:	 bool : true if checksum calculated correctly, false otherwise
ARGUMENTS:	 none

⌨️ 快捷键说明

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