当前位置: 首页>>代码示例>>C++>>正文


C++ MD5::digestString方法代码示例

本文整理汇总了C++中MD5::digestString方法的典型用法代码示例。如果您正苦于以下问题:C++ MD5::digestString方法的具体用法?C++ MD5::digestString怎么用?C++ MD5::digestString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MD5的用法示例。


在下文中一共展示了MD5::digestString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkPass

void checkPass(char* hashFile, char* tempString, int myRank, char* type)
{
	int i;
	bool foundPass = false;
    char str[SHA256_HASH_LENGTH+1];
    char testHash[SHA256_HASH_LENGTH+1];

    if (strcmp(type, "MD5") == 0)
    {
        sprintf(testHash, "%s", md5.digestString(tempString));
    }
    else if (strcmp(type, "SHA1") == 0)
    {
        unsigned char binaryHash[SHA_DIGEST_LENGTH];
        unsigned char* sha1String = (unsigned char*)tempString;

        SHA1(sha1String, strlen(tempString), binaryHash);
        for (i = 0; i < SHA_DIGEST_LENGTH; i++)
            sprintf(testHash+2*i, "%02x", binaryHash[i]);
    }
    else if (strcmp(type, "SHA256") == 0)
    {
        unsigned char binaryHash[SHA256_DIGEST_LENGTH];
        unsigned char* sha256String = (unsigned char*)tempString;

        SHA256(sha256String, strlen(tempString), binaryHash);
        for (i = 0; i < SHA256_DIGEST_LENGTH; i++)
            sprintf(testHash+2*i, "%02x", binaryHash[i]);
    }
//    printf("Proc %d: %s\n", myRank, tempString); // Debugging info

    FILE* pFile;
    
    pFile = fopen (hashFile,"r");
    if (pFile == NULL) {
        perror ("Error opening file, aborting\n");
        MPI_Finalize();
        exit(-3);
    }

    while (fscanf (pFile, "%s", str) != EOF)
    {
        foundPass = (strcmp(testHash, str) == 0);
       	if (foundPass) {
    		printf("%s, %s\n", tempString, testHash);
    	}
    }
    fclose (pFile);
} 
开发者ID:kpachhai,项目名称:HPCPC,代码行数:49,代码来源:mpi_brute_force.cpp

示例2: checkPass

void checkPass(char* hash, char* tempString)
{
    char testHash[HASH_LENGTH];
	int i;
	bool foundPass = false;
    sprintf(testHash, "%s", md5.digestString(tempString));
    
//    printf("%s\n", tempString);
	for (i = 0; i < HASH_LENGTH; i++) {// Checks if the hashes match
		if (testHash[i] != hash[i]) {
			foundPass = false;
			break;
		} else {
			foundPass = true;
		}
	}
	if (foundPass) {
		printf("The password is %s\n", tempString);
		exit(0);
	}
}
开发者ID:kpachhai,项目名称:HPCPC,代码行数:21,代码来源:omp_brute_force.cpp


注:本文中的MD5::digestString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。