CID ClientManager::makeCid(const string& aNick, const string& aHubUrl) const throw() { string n = Text::toLower(aNick); TigerHash th; th.update(n.c_str(), n.length()); th.update(Text::toLower(aHubUrl).c_str(), aHubUrl.length()); // Construct hybrid CID from the bits of the tiger hash - should be // fairly random, and hopefully low-collision return CID(th.finalize()); }
void AdcHub::password(const string& pwd) { if(state != STATE_VERIFY) return; if(!salt.empty()) { static const int SALT_SIZE = 192/8; u_int8_t buf[SALT_SIZE]; Encoder::fromBase32(salt.c_str(), buf, SALT_SIZE); const string& x = pwd; TigerHash th; th.update(getMe()->getCID().getData(), CID::SIZE); th.update(x.data(), x.length()); th.update(buf, SALT_SIZE); send("HPAS " + getMe()->getCID().toBase32() + " " + Encoder::toBase32(th.finalize(), TigerHash::HASH_SIZE) + "\n"); salt.clear(); } }
static void __cdecl loadFlash_Thread(void *p) { debug("Avatar thread executed...\n"); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE); flash_avatar_item* fai = (flash_avatar_item*)p; IShockwaveFlash* flash = fai->pFlash; if ( _tcschr(fai->hFA.cUrl, '?') == NULL) { // make hash of url debug("Making TTH hash from URL...\n"); TigerHash th; th.update(fai->hFA.cUrl, _tcslen(fai->hFA.cUrl)); th.finalize(); // create local path name TCHAR name[MAX_PATH], path[MAX_PATH]; TCHAR tth[((TigerHash::HASH_SIZE * 8) / 5) + 2]; FOLDERSGETDATA fgd = {0}; fgd.cbSize = sizeof(FOLDERSGETDATA); fgd.nMaxPathSize = MAX_PATH; fgd.szPathT = path; fgd.flags = FF_TCHAR; if (!hAvatarsFolder || CallService(MS_FOLDERS_GET_PATH, (WPARAM)hAvatarsFolder, (LPARAM)&fgd)) { if(ServiceExists(MS_UTILS_REPLACEVARS)) mir_sntprintf(path, MAX_PATH, _T("%s\\%s"), VARST(_T("%miranda_avatarcache%")), _T("Flash")); else PathToAbsoluteT( _T("Flash"), path); } else { if(_tcslen(path) && path[_tcslen(path)-1]=='\\') path[_tcslen(path)-1] = 0; } CreateDirectory(path, NULL); // create directory if it doesn't exist mir_sntprintf(name, MAX_PATH, _T("%s\\%s.swf"), path, th.toBase32(tth)); // download remote file if it doesn't exist if (GetFileAttributes(name) == 0xFFFFFFFF) { debug("Downloading flash file...\n"); DownloadFlashFile( _T2A(fai->hFA.cUrl), name, 0); } // load and play local flash movie debug("Loading flash movie...\n"); flash->LoadMovie(0, _bstr_t(name).copy()); } Sleep(100); flash->Play(); // change flash frame according user's status int status; if (fai->hFA.hContact) status = db_get_w(fai->hFA.hContact, fai->getProto(), "Status", ID_STATUS_OFFLINE); else status = CallProtoService(fai->getProto(), PS_GETSTATUS, 0, 0); getFace(); flash->SetVariable(L"face.emotion", _bstr_t(face).copy()); flash->Release(); }
CID ClientManager::getMyCID() { TigerHash tiger; tiger.update(getMyPID().data(), CID::SIZE); return CID(tiger.finalize()); }