AnsiString HashCreator::GenerateHash(const AnsiString &inputString, const AnsiString &salt) { AnsiString saltString = salt; if (saltString.GetLength() == 0 && _hashType == SHA256) { AnsiString randomString = PasswordGenerator::Generate(); saltString = _GetHash(randomString, hex); saltString = saltString.Mid(0, SALT_LENGTH); } AnsiString value = saltString + _GetHash(saltString + inputString, hex); return value; }
bool HashCreator::ValidateHash(const AnsiString &password, const AnsiString &originalHash, bool useSalt) { if (useSalt) { AnsiString salt = _GetSalt(originalHash); AnsiString result = GenerateHash(password, salt); if (result == originalHash) return true; else return false; } else { AnsiString result = _GetHash(password, hex); if (result == originalHash) return true; else return false; } }
void HashMap::Add(ReadSequence *rs) { uint32_t rid_hash = _GetHash((*rs).readID) % this->size; HashEntry *h = new HashEntry(rid_hash); h->SetValue(rs); if(this->Get(rs) == NULL) { this->_map[rid_hash]->push_back(h); this->item_count++; } }
bool HdxIntersector::Result::ResolveUnique(HdxIntersector::HitSet* hitSet) const { TRACE_FUNCTION(); if (!IsValid()) { return false; } int width = _viewport[2]; int height = _viewport[3]; std::unordered_map<size_t, int> hitIndices; { HD_TRACE_SCOPE("unique indices"); size_t previousHash = 0; for (int i = 0; i < width * height; ++i) { size_t hash = _GetHash(i); // As an optimization, keep track of the previous hash value and // reject indices that match it without performing a map lookup. // Adjacent indices are likely enough to have the same prim, // instance and element ids that this can be a significant // improvement. if (hitIndices.empty() || hash != previousHash) { hitIndices.insert(std::make_pair(hash, i)); previousHash = hash; } } } int hitCount = 0; { HD_TRACE_SCOPE("resolve"); float const* depths = _depths.get(); TF_FOR_ALL(it, hitIndices) { int index = it->second; int x = index % width; int y = index / width; Hit hit; if (_ResolveHit(index, x, y, depths[index], &hit)) { hitCount++; if (hitSet) { hitSet->insert(hit); } } } }
ReadSequence* HashMap::Get(ReadSequence *rs) { uint32_t rid_hash = _GetHash((*rs).readID) % this->size; if(this->_map[rid_hash]->size() == 0) return NULL; std::vector< HashEntry* >::iterator h_iter; std::vector< HashEntry* > *h; h = this->_map[rid_hash]; for(h_iter = h->begin(); h_iter != h->end(); h_iter++) { if((*h_iter)->Equals(rs)) return (*h_iter)->GetValue(); } return NULL; }
AnsiString HashCreator::GenerateHashNoSalt(const AnsiString &inputString, RequestedEncoding encoding) { return _GetHash(inputString, encoding); }