www.gusucode.com > VC++实现QQ自动登陆器源程序-源码程序 > VC++实现QQ自动登陆器源程序-源码程序\code\GetHash.cpp

    //Download by http://www.NewXing.com
// GetHash.cpp: implementation of the GetHash class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "GetHash.h"
#include "MD5Checksum.h"


#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

GetHash::GetHash()
{
	
}

GetHash::~GetHash()
{
	
}



CString GetHash::hexToBin(CString inPutHex)
{
	CString getBinValue;
	for(int i=0;i<inPutHex.GetLength();i++)
	{
		switch (inPutHex[i])
		{
        case '0':
			getBinValue+="0000";
			break;
		case '1':
			getBinValue+="0001";
			break;
		case '2':
			getBinValue+="0010";
			break;
		case '3':
			getBinValue+="0011";
			break;
		case '4':
			getBinValue+="0100";
			break;
		case '5':
			getBinValue+="0101";
			break;
		case '6':
			getBinValue+="0110";
			break;
		case '7':
			getBinValue+="0111";
			break;
		case '8':
			getBinValue+="1000";
			break;
		case '9':
			getBinValue+="1001";
			break;
		case 'a':
			getBinValue+="1010";
			break;
		case 'b':
			getBinValue+="1011";
			break;
		case 'c':
			getBinValue+="1100";
			break;
		case 'd':
			getBinValue+="1101";
			break;
		case 'e':
			getBinValue+="1110";
			break;
		case 'f':
			getBinValue+="1111";
			break;
		case 'A':
			getBinValue+="1010";
			break;
		case 'B':
			getBinValue+="1011";
			break;
		case 'C':
			getBinValue+="1100";
			break;
		case 'D':
			getBinValue+="1101";
			break;
		case 'E':
			getBinValue+="1110";
			break;
		case 'F':
			getBinValue+="1111";
			break;
		};		
	}
	return getBinValue;
}

CString GetHash::FindTable(const CString bin)
{
	if(bin=="000000")
		return "A";
	if(bin=="000001")
		return "B";
	if(bin=="000010")
		return "C";
	if(bin=="000011")
		return "D";
	if(bin=="000100")
		return "E";
	if(bin=="000101")
		return "F";
	if(bin=="000110")
		return "G";
	if(bin=="000111")
		return "H";
	if(bin=="001000")
		return "I";
	if(bin=="001001")
		return "J";
	if(bin=="001010")
		return "K";
	if(bin=="001011")
		return "L";
	if(bin=="001100")
		return "M";
	if(bin=="001101")
		return "N";
	if(bin=="001110")
		return "O";
	if(bin=="001111")
		return "P";
	if(bin=="010000")
		return "Q";
	if(bin=="010001")
		return "R";
	if(bin=="010010")
		return "S";
	if(bin=="010011")
		return "T";
	if(bin=="010100")
		return "U";
	if(bin=="010101")
		return "V";
	if(bin=="010110")
		return "W";
	if(bin=="010111")
		return "X";
	if(bin=="011000")
		return "Y";
	if(bin=="011001")
		return "Z";
	if(bin=="011010")
		return "a";
	if(bin=="011011")
		return "b";
	if(bin=="011100")
		return "c";
	if(bin=="011101")
		return "d";
	if(bin=="011110")
		return "e";
	if(bin=="011111")
		return "f";
	if(bin=="100000")
		return "g";
	if(bin=="100001")
		return "h";
	if(bin=="100010")
		return "i";
	if(bin=="100011")
		return "j";
	if(bin=="100100")
		return "k";
	if(bin=="100101")
		return "l";
	if(bin=="100110")
		return "m";
	if(bin=="100111")
		return "n";
	if(bin=="101000")
		return "o";
	if(bin=="101001")
		return "p";
	if(bin=="101010")
		return "q";
	if(bin=="101011")
		return "r";
	if(bin=="101100")
		return "s";
	if(bin=="101101")
		return "t";
	if(bin=="101110")
		return "u";
	if(bin=="101111")
		return "v";
	if(bin=="110000")
		return "w";
	if(bin=="110001")
		return "x";
	if(bin=="110010")
		return "y";
	if(bin=="110011")
		return "z";
	if(bin=="110100")
		return "0";
	if(bin=="110101")
		return "1";
	if(bin=="110110")
		return "2";
	if(bin=="110111")
		return "3";
	if(bin=="111000")
		return "4";
	if(bin=="111001")
		return "5";
	if(bin=="111010")
		return "6";
	if(bin=="111011")
		return "7";
	if(bin=="111100")
		return "8";
	if(bin=="111101")
		return "9";
	if(bin=="111110")
		return "+";
	if(bin=="111111")
		return "/";
	return "";
}


CString GetHash::GetMyHash(CString CstrPassword)
{
	CString getMd5;
	getMd5 = CMD5Checksum::GetMD5( (BYTE*)(const char*)CstrPassword, CstrPassword.GetLength() );	
	
	CString CstrBin=hexToBin(getMd5)+"0000";
	
	CString  CstrHashValue,CstrGet8Bin;
	for(int i=0;i<22;i++)
	{
		CstrGet8Bin=CstrBin.Mid(i*6,6);
		CstrHashValue+=FindTable(CstrGet8Bin);
	}
	return CstrHashValue+"==";
}