md5.cpp

来自「MD5算法C语言实现.rar非常好的一个算法」· C++ 代码 · 共 65 行

CPP
65
字号
// MD5.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "md5.h"
#include "stdlib.h"
#include "string.h"



int main(int argc, char* argv[])
{
	char t[80], path[80];
	
	printf( "****************************A Md5 generator**************************\n");
	printf( "Usage: Type the full path of a file or drag the file icon            \n");
	printf( "       into the window by mouse, then press enter.                   \n");
	printf( "Input path of the file:");
	gets( t);

	for( int i = 0, j = 0; i < strlen(t); i ++)
	{
		if( t[i] != 34)
		{
			path[j] = t[i];
			if( t[i] == 92)
			{
				path[j+1] = path[j];
				j ++;
			}
			j ++;
		}
	}

	path[j] = '\0';
	
	FILE *fp = fopen( path, "rb");
	if(fp == NULL)
	{
		printf("Can't open the file!\n");
		system( "pause");
		return 1;
	}

	unsigned char md5[16];

	unsigned f_size = Md5( fp, md5);

	cout << "FileSize:" << f_size << " Bytes" << endl;

	printf( "Md5:");

	for( i = 0; i < 16; i ++)
	{
		printf( "%x", (md5[i] >> 4) & 0xf);
		printf( "%x", md5[i] & 0xf);
	}
	
	cout << endl;

	system( "pause");
	return 0;
}

⌨️ 快捷键说明

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