コード例 #1
0
ファイル: flashtool.cpp プロジェクト: FFTEAM/evolux-spark-sh4
bool CFlashTool::check_md5( const std::string & filename, const std::string & smd5)
{
	unsigned char md5[16];
	unsigned char omd5[16];

	const char * ptr = smd5.c_str();

	if(strlen(ptr) < 32)
		return false;
//printf("[flashtool] check file %s md5 %s\n", filename.c_str(), ptr);

	for(int i = 0; i < 16; i++)
		omd5[i] = FROMHEX(ptr[i*2])*16 + FROMHEX(ptr[i*2+1]);

	md5_file(filename.c_str(), 1, md5);
	if(memcmp(md5, omd5, 16))
		return false;
	return true;
}
コード例 #2
0
ファイル: BaseFile.cpp プロジェクト: zhangshpX/Test
//URL解码pOut使用完后需要free
void URLDecode(const char* szIn, char** pOut)
{
	int nInLenth = (int) strlen( szIn );
	int nFlag = 0;
	*pOut = (char*)malloc(nInLenth+1);
	char* szOut = *pOut;
	for (int i = 0; i < nInLenth; i++)
	{
		if (szIn[i] == '%')
		{
			szOut[nFlag] = (FROMHEX(szIn[i+1])<<4);
			szOut[nFlag] |= FROMHEX(szIn[i+2]);
			i += 2;
		}
		else
		{
			szOut[nFlag] = szIn[i];
		}
		nFlag++;
	}
	szOut[nFlag] = '\0';
}