引用(patricxu @ 2009-06-24, 10:51 PM)

我正在为这个问题而困惑。自己没有找到ID生成的代码。楼主可知道?
电驴里的源代码:
1.
m_uClientID.SetValueRandom();
CUInt128& CUInt128::SetValueRandom()
{
AutoSeededRandomPool rng;
byte byRandomBytes[16];
rng.GenerateBlock(byRandomBytes, 16);
SetValueBE( byRandomBytes );
return *this;
}
2.
m_uClientHash.SetValue((uchar*)thePrefs.GetUserHash());
void CPreferences::CreateUserHash()
{
try
{
do {
/*
for (int i = 0; i < 8; i++)
{
uint16 random = GetRandomUInt16();
memcpy(&userhash[i*2], &random, 2);
}
*/
Kademlia::CUInt128 u128;
u128.SetValueRandom();
memcpy(userhash,u128.GetData(),16);
// mark as emule client. that will be need in later version
userhash[5] = 14;
userhash[14] = 111;
} while(CGlobalVariable::dlp && CGlobalVariable::dlp->IsDLPavailable() && CGlobalVariable::dlp->DLPCheckUserhash(userhash) != NULL );
}
catch (...)
{
}
}
[0]
[0]
[回复]