SA-MP/saco/archive/Hasher.cpp

45 lines
895 B
C++
Raw Normal View History

2023-11-08 20:29:53 +08:00
#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;
}
//------------------------------------