コード例 #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
bool
	RecordHandle::FindName()
{
	Check_Object(this);
	Check_Object(m_databaseHandle);
	Database* db = m_databaseHandle->m_dataBase;
	Check_Object(db);

	Check_Pointer(m_name);
	DWORD hash = GenerateHash(m_name);
	DWORD index = hash % Database::e_DataBlockSize;

	Record* record = reinterpret_cast<Record*>(db->m_nameOffsets[index]);
	while (record)
	{
		record = reinterpret_cast<Record*>(
			(DWORD)record + m_databaseHandle->m_baseAddress
		);
		Check_Object(record);
		if (record->m_hash == hash && !_stricmp(m_name,record->m_name))
		{
			m_length = record->m_length;
			m_data = &record->m_data[record->m_nameLength];
			m_ID = record->m_ID;
			m_name = record->m_name;
			m_record = record;
			m_timeStamp = record->m_lastModified;
			return true;
		}
		record = reinterpret_cast<Record*>(record->m_nextNameRecord);
	}	

	m_record = NULL;
	return false;
}
コード例 #2
0
ファイル: HashCreator.cpp プロジェクト: Bill48105/hmailserver
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;
    }


}
コード例 #3
0
ファイル: HashTable.cpp プロジェクト: sefbkn/Randoms
Node* FindValue(HashTable* hashTable, char* key)
{
    if(hashTable != NULL)
    {
        int hashOffset = GenerateHash((char*)key) % hashTable->totalBucketCount;
        if(hashTable->nodeTable[hashOffset] != NULL)
        {
            return FindNode(hashTable->nodeTable[hashOffset], key);
        }
    }
    return NULL;
}
コード例 #4
0
ファイル: HashTable.cpp プロジェクト: sefbkn/Randoms
void RemoveValue(HashTable* hashTable, char* key)
{
    if(hashTable != NULL)
    {
        int hashOffset = GenerateHash((char*)key) % hashTable->totalBucketCount;
        if(hashTable->nodeTable[hashOffset] != NULL)
        {
            RemoveNode(hashTable->nodeTable[hashOffset], key);
            hashTable->nodeTable[hashOffset] = NULL;
        }
    }
}
コード例 #5
0
ファイル: ShaderCompilation.cpp プロジェクト: MehdiNS/Shadows
static wstring MakeShaderCacheName(const std::string& shaderCode, const char* functionName,
                                   const char* profile, const D3D_SHADER_MACRO* defines)
{
    string hashString = shaderCode;
    hashString += "\n";
    hashString += functionName;
    hashString += "\n";
    hashString += profile;
    hashString += "\n";

    hashString += MakeDefinesString(defines);

    Hash codeHash = GenerateHash(hashString.data(), int(hashString.length()), 0);

    return cacheDir + codeHash.ToString() + L".cache";
}
コード例 #6
0
ファイル: HashTable.cpp プロジェクト: sefbkn/Randoms
Node* AddValue(HashTable* hashTable, char* key, char* value)
{
    if(hashTable != NULL)
    {
        int hashOffset = GenerateHash((char*)key) % hashTable->totalBucketCount;
        if(hashTable->nodeTable[hashOffset] == NULL)
        {
            hashTable->nodeTable[hashOffset] = NewNode(key, value);
            return hashTable->nodeTable[hashOffset];
        }

        else
        {
            return AddNode(hashTable->nodeTable[hashOffset], key, value);
        }
    }
}
コード例 #7
0
static void CompileShader(CompiledShader* shader)
{
    Assert_(shader != nullptr);

    GrowableList<wstring> filePaths;
    D3D_SHADER_MACRO defines[CompileOptions::MaxDefines + 1];
    shader->CompileOpts.MakeDefines(defines);
    shader->ByteCode = CompileShader(shader->FilePath.c_str(), shader->FunctionName.c_str(),
                                     shader->Type, shader->Profile, defines,
                                     shader->ForceOptimization, filePaths);
    shader->ByteCodeHash = GenerateHash(shader->ByteCode->GetBufferPointer(), int(shader->ByteCode->GetBufferSize()));

    for(uint64 fileIdx = 0; fileIdx < filePaths.Count(); ++ fileIdx)
    {
        const wstring& filePath = filePaths[fileIdx];
        ShaderFile* shaderFile = nullptr;
        for(uint64 shaderFileIdx = 0; shaderFileIdx < ShaderFiles.Count(); ++shaderFileIdx)
        {
            if(ShaderFiles[shaderFileIdx]->FilePath == filePath)
            {
                shaderFile = ShaderFiles[shaderFileIdx];
                break;
            }
        }
        if(shaderFile == nullptr)
        {
            shaderFile = new ShaderFile(filePath);
            ShaderFiles.Add(shaderFile);
        }

        bool containsShader = false;
        for(uint64 shaderIdx = 0; shaderIdx < shaderFile->Shaders.Count(); ++shaderIdx)
        {
            if(shaderFile->Shaders[shaderIdx] == shader)
            {
                containsShader = true;
                break;
            }
        }

        if(containsShader == false)
            shaderFile->Shaders.Add(shader);
    }
}
コード例 #8
0
bool GOrgueArchiveIndex::WriteContent(const wxString& id, const std::vector<GOArchiveEntry>& entries)
{
	int magic = GRANDORGUE_INDEX_MAGIC;
	if (!Write(&magic, sizeof(magic)))
		return false;

	GOrgueHashType hash = GenerateHash();
	if (!Write(&hash, sizeof(hash)))
		return false;

	if (!WriteString(id))
		return false;

	unsigned cnt = entries.size();
	if (!Write(&cnt, sizeof(cnt)))
	    return false;
	for(unsigned i = 0; i < entries.size(); i++)
		if (!WriteEntry(entries[i]))
			return false;

	return true;
}
コード例 #9
0
bool GOrgueArchiveIndex::ReadIndex(wxString& id, std::vector<GOArchiveEntry>& entries)
{
	wxString name = GenerateIndexFilename();
	if (!wxFileExists(name))
		return false;
	if (!m_File.Open(name, wxFile::read))
	{
		wxLogError(_("Failed to open '%s'"), name.c_str());
		return false;
	}

	int magic;
	GOrgueHashType hash1, hash2;
	hash1 = GenerateHash();

	if (!Read(&magic, sizeof(magic)) || !Read(&hash2, sizeof(hash2)))
	{
		m_File.Close();
		wxLogError(_("Failed to read '%s'"), name.c_str());
		return false;
	}
	if (magic != GRANDORGUE_INDEX_MAGIC || memcmp(&hash1, &hash2, sizeof(hash1)))
	{
		m_File.Close();
		wxLogError(_("Index '%s' has bad magic - bypassing index"), name.c_str());
		return false;
	}

	if (!ReadContent(id, entries))
	{
		m_File.Close();
		wxLogError(_("Failed to read '%s'"), name.c_str());
		return false;
	}

	m_File.Close();
	return true;
}
コード例 #10
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	RecordHandle::Replace()
{
	Check_Object(this);
	gos_PushCurrentHeap(Database_Heap);

	//
	//------------------
	// Find our database
	//------------------
	//
	Check_Object(m_databaseHandle);
	Verify(!m_databaseHandle->m_readOnly);
	m_databaseHandle->m_dirtyFlag = true;
	
	//
	//----------------------
	// Unhook the old record
	//----------------------
	//
	Check_Object(m_record);
	const_cast<Record*>(m_record)->Unhook(this);

	//
	//---------------------------------------------------
	// Figure out how long the name is and its hash value
	//---------------------------------------------------
	//
	DWORD record_hash, name_length;
	if (m_name)
	{
		record_hash = GenerateHash(m_name);
		name_length = strlen(m_name);
		Verify(name_length > 0);
	}
	else
	{
		record_hash = 0;
		name_length = 0;
	}

	//
	//------------------
	// Set up the record
	//------------------
	//
	Record *data =
		new(new BYTE[sizeof(*m_record) + m_length + name_length])
			Record(this, record_hash, name_length);
	Check_Object(data);
	m_data = &data->m_name[name_length+1];
	if (m_name)
		m_name = data->m_name;
	m_timeStamp = data->m_lastModified;

	//
	//------------------
	// Update statistics
	//------------------
	//
	if (m_record->m_mustFree)
		delete const_cast<Record*>(m_record);
	m_record = data;
	gos_PopCurrentHeap();
}
コード例 #11
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	RecordHandle::Add()
{
	Check_Object(this);
	gos_PushCurrentHeap(Database_Heap);

	//
	//------------------
	// Find our database
	//------------------
	//
	Check_Object(m_databaseHandle);
	Verify(!m_databaseHandle->m_readOnly);
	m_databaseHandle->m_dirtyFlag = true;
	Database* db = m_databaseHandle->m_dataBase;
	Check_Object(db);

	//
	//-------------------------------------------
	// Make sure the record doesn't already exist
	//-------------------------------------------
	//
	Verify(!m_record);
	#ifdef _ARMOR
		if (m_name)
		{
			RecordHandle dup_check = *this;
			if (dup_check.FindName())
				STOP(( "Duplicate Record" ));
		}
	#endif
	
	//
	//------------------
	// Set the record index
	//------------------
	//
	m_ID=db->m_nextRecordID++;

	//
	//---------------------------------------------------
	// Figure out how long the name is and its hash value
	//---------------------------------------------------
	//
	DWORD record_hash, name_length;
	if (m_name)
	{
		record_hash = GenerateHash(m_name);
		name_length = strlen(m_name);
		Verify(name_length > 0);
	}
	else
	{
		record_hash = 0;
		name_length = 0;
	}

	//
	//------------------
	// Set up the record
	//------------------
	//
	Verify(!m_record);
	Record *data =
		new(new BYTE[sizeof(*m_record) + m_length + name_length])
			Record(this, record_hash, name_length);
	Check_Object(data);
	m_data = &data->m_name[name_length+1];
	if (m_name)
		m_name = data->m_name;
	m_timeStamp = data->m_lastModified;

	//
	//------------------
	// Update statistics
	//------------------
	//
	m_record = data;
	gos_PopCurrentHeap();
}
コード例 #12
0
ファイル: main.c プロジェクト: gale320/cc3200
//*****************************************************************************
//
//! main - populate the parameters from predefines Test Vector or User
//!
//! \param None
//!
//! \return None
//
//*****************************************************************************
void
main()
{
    unsigned int uiConfig,uiHashLength,uiDataLength;
    unsigned char *puiKey1,*puiData,*puiResult;
    unsigned int u8count;
#ifndef USER_INPUT
    unsigned char *puiTempExpResult;
#endif
    //
    // Initialize board configurations
    BoardInit();
    //
    // Configuring UART for Receiving input and displaying output
    // 1. PinMux setting
    // 2. Initialize UART
    // 3. Displaying Banner
    //
    PinMuxConfig();
    InitTerm();
    DisplayBanner(APP_NAME);

    //
    // Enable the module .
    //
    MAP_PRCMPeripheralClkEnable(PRCM_DTHE, PRCM_RUN_MODE_CLK);
    //
    // Enable interrupts.
    //
    MAP_SHAMD5IntRegister(SHAMD5_BASE, SHAMD5IntHandler);

#ifdef USER_INPUT
    while(FOREVER)
    {
        //
        // Read values either from User or from Vector based on macro USER_INPUT
        // defined or not
        //

        //
        // Read the values from the user over uart and Populate the variables
        //
        puiData=ReadFromUser(&uiConfig,&uiHashLength,&puiKey1,&uiDataLength,
                             &puiResult);
        if(puiData==NULL)
        {
            continue;
        }
#else
    //
    // Load Default values
    //
    UART_PRINT("Running Keyed Hashing HMAC_MD5\n\r\n\r");
    UART_PRINT("loading default values\n\r\n\r");
    uiHMAC=1;
    puiData= LoadDefaultValues(SHAMD5_ALGO_HMAC_MD5,&uiConfig,&uiHashLength,
                               &puiKey1,&uiDataLength,&puiResult);
    UART_PRINT("Data Length (in Bytes) %d\n\r\n\r",uiDataLength);
#endif

        //
        // Generate Hash Value
        //
        UART_PRINT("\n\rHashing in Progress... \n\r");
        GenerateHash(uiConfig,puiKey1,puiData,puiResult,uiDataLength);
        UART_PRINT("Hash Value is generated\n\r");
        //
        // Display/Verify Result
        //

#ifdef USER_INPUT
        //
        // Display Hash Value Generated
        //
        UART_PRINT("\n\r The Hash Value in Hex is: 0x%02x",*puiResult);
        for(u8count=0; u8count<(uiHashLength/4); u8count++)
        {
            UART_PRINT("%02x",*(puiResult+u8count));
        }
        UART_PRINT("\n\r");
    } //end while(FOREVER)
#else
        //
        // Comapre Hash Generated and expected values from predefined vector
        //
        UART_PRINT("Hash Length (in Bytes) %d\n\r\n\r",uiHashLength);
        UART_PRINT("\n\r Computed Hash Value in Hex is: ");
        for(u8count=0; u8count<uiHashLength; u8count++)
        {
            UART_PRINT("%02x",*(puiResult+u8count));
        }
        UART_PRINT("\n\r");

        puiTempExpResult = (unsigned char *)g_psHMACShaMD5TestVectors.puiExpectedHash;

        UART_PRINT("\n\r Expected Hash Value in Hex is: ");
        for(u8count=0; u8count<uiHashLength; u8count++)
        {
            UART_PRINT("%02x",*(puiTempExpResult+u8count));
        }
        UART_PRINT("\n\r");

        if(memcmp(puiResult,g_psHMACShaMD5TestVectors.puiExpectedHash,uiHashLength)==0)
        {
            UART_PRINT("\n\r Hashing verified successfully");
        }
        else
        {
            UART_PRINT("\n\r Error in Hashing computation");
        }
        while(FOREVER);
#endif


}
コード例 #13
0
//---------------------------------------
EventTag EventListener::TagFromString( const std::string& stringTag )
{
	return GenerateHash( stringTag.c_str() );
}
コード例 #14
0
void PostProcessHelper::PostProcess(CompiledShaderPtr pixelShader, const char* name, const uint32* inputs, uint64 numInputs,
                                    const RenderTexture*const* outputs, uint64 numOutputs)
{
    Assert_(cmdList != nullptr);
    Assert_(numOutputs > 0);
    Assert_(outputs != nullptr);
    Assert_(numInputs == 0 || inputs != nullptr);
    Assert_(numInputs <= MaxInputs);

    PIXMarker marker(cmdList, name);

    HashSource hashSource;
    for(uint64 i = 0; i < numOutputs; ++i)
    {
        hashSource.OutputFormats[i] = outputs[i]->Texture.Format;
        hashSource.MSAASamples = outputs[i]->MSAASamples;
    }

    Hash psoHash = GenerateHash(&hashSource, sizeof(HashSource));
    psoHash = CombineHashes(psoHash, pixelShader->ByteCodeHash);

    ID3D12PipelineState* pso = nullptr;

    // The most linear of searches!
    const uint64 numPSOs = pipelineStates.Count();
    for(uint64 i = 0; i < numPSOs; ++i)
    {
        if(pipelineStates[i].Hash == psoHash)
        {
            pso = pipelineStates[i].PSO;
            break;
        }
    }

    if(pso == nullptr)
    {
        D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
        psoDesc.pRootSignature = rootSignature;
        psoDesc.VS = fullScreenTriVS.ByteCode();
        psoDesc.PS = pixelShader.ByteCode();
        psoDesc.RasterizerState = DX12::GetRasterizerState(RasterizerState::NoCull);
        psoDesc.BlendState = DX12::GetBlendState(BlendState::Disabled);
        psoDesc.DepthStencilState = DX12::GetDepthState(DepthState::Disabled);
        psoDesc.SampleMask = UINT_MAX;
        psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
        psoDesc.NumRenderTargets = uint32(numOutputs);
        for(uint64 i = 0; i < numOutputs; ++i)
            psoDesc.RTVFormats[i] = hashSource.OutputFormats[i];
        psoDesc.DSVFormat = DXGI_FORMAT_UNKNOWN;
        psoDesc.SampleDesc.Count = uint32(hashSource.MSAASamples);
        DXCall(DX12::Device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pso)));

        CachedPSO cachedPSO;
        cachedPSO.Hash = psoHash;
        cachedPSO.PSO = pso;
        pipelineStates.Add(cachedPSO);
    }

    D3D12_CPU_DESCRIPTOR_HANDLE rtvHandles[8] = { };
    for(uint64 i = 0; i < numOutputs; ++i)
        rtvHandles[i] = outputs[i]->RTV;
    cmdList->OMSetRenderTargets(uint32(numOutputs), rtvHandles, false, nullptr);

    cmdList->SetGraphicsRootSignature(rootSignature);
    cmdList->SetPipelineState(pso);

    DX12::BindStandardDescriptorTable(cmdList, RootParam_StandardDescriptors, CmdListMode::Graphics);

    AppSettings::BindCBufferGfx(cmdList, RootParam_AppSettings);

    uint32 srvIndices[MaxInputs] = { };
    for(uint64 i = 0; i < numInputs; ++i)
        srvIndices[i] = inputs[i];
    for(uint64 i = numInputs; i < MaxInputs; ++i)
        srvIndices[i] = DX12::NullTexture2DSRV;

    DX12::BindTempConstantBuffer(cmdList, srvIndices, RootParam_SRVIndices, CmdListMode::Graphics);

    DX12::SetViewport(cmdList, outputs[0]->Texture.Width, outputs[0]->Texture.Height);

    cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    cmdList->DrawInstanced(3, 1, 0, 0);

}