mirror of
https://github.com/dashr9230/SA-MP.git
synced 2024-12-22 14:37:29 +08:00
45 lines
895 B
C++
45 lines
895 B
C++
|
|
#include "Hasher.h"
|
|
#include "CryptoFns.h"
|
|
|
|
//------------------------------------
|
|
|
|
DWORD CHasher::ms_dwHashAlgorithm = CALG_SHA1;
|
|
|
|
//------------------------------------
|
|
|
|
CHasher::CHasher(CCryptoContext* pContext)
|
|
{
|
|
// Save context for later
|
|
m_pContext = pContext;
|
|
|
|
// Generate a hash container
|
|
HCRYPTPROV hCryptProv = pContext->GetProvider();
|
|
CRYPT(CreateHash)(hCryptProv, ms_dwHashAlgorithm, NULL, NULL, &m_hCryptHash);
|
|
}
|
|
|
|
//------------------------------------
|
|
|
|
CHasher::~CHasher(void)
|
|
{
|
|
// Destory the hash container
|
|
CRYPT(DestroyHash)(m_hCryptHash);
|
|
}
|
|
|
|
//------------------------------------
|
|
|
|
void CHasher::AddData(DWORD dwDataLength, BYTE *pbData)
|
|
{
|
|
// Add the data to be hashed
|
|
CRYPT(HashData)(m_hCryptHash, pbData, dwDataLength, 0);
|
|
}
|
|
|
|
//------------------------------------
|
|
|
|
HCRYPTKEY CHasher::GetContainer()
|
|
{
|
|
return m_hCryptHash;
|
|
}
|
|
|
|
//------------------------------------
|