Continue move to CMake
This commit is contained in:
@@ -14,17 +14,17 @@ SString GenerateSha256(const SString& str)
|
||||
SString ret;
|
||||
HCRYPTPROV hCryptProv = 0;
|
||||
HCRYPTHASH hHash = 0;
|
||||
BOOL ok = CryptAcquireContext(&hCryptProv, nullptr, nullptr, PROV_RSA_AES, 0);
|
||||
ok = ok && CryptCreateHash(hCryptProv, CALG_SHA_256, 0, 0, &hHash);
|
||||
ok = ok && CryptHashData(hHash, reinterpret_cast<const BYTE*>(&str[0]), str.ByteLength(), 0);
|
||||
BOOL ok = ::CryptAcquireContext(&hCryptProv, nullptr, nullptr, PROV_RSA_AES, 0);
|
||||
ok = ok && ::CryptCreateHash(hCryptProv, CALG_SHA_256, 0, 0, &hHash);
|
||||
ok = ok && ::CryptHashData(hHash, reinterpret_cast<const BYTE*>(&str[0]), str.ByteLength(), 0);
|
||||
if (ok)
|
||||
{
|
||||
DWORD dwHashLen;
|
||||
DWORD dwCount = sizeof(DWORD);
|
||||
if (CryptGetHashParam(hHash, HP_HASHSIZE, reinterpret_cast<BYTE *>(&dwHashLen), &dwCount, 0))
|
||||
if (::CryptGetHashParam(hHash, HP_HASHSIZE, reinterpret_cast<BYTE *>(&dwHashLen), &dwCount, 0))
|
||||
{
|
||||
std::vector<unsigned char> hash(dwHashLen);
|
||||
if (CryptGetHashParam(hHash, HP_HASHVAL, reinterpret_cast<BYTE *>(&hash[0]), &dwHashLen, 0))
|
||||
if (::CryptGetHashParam(hHash, HP_HASHVAL, reinterpret_cast<BYTE *>(&hash[0]), &dwHashLen, 0))
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << std::hex << std::uppercase << std::setfill('0');
|
||||
@@ -37,8 +37,8 @@ SString GenerateSha256(const SString& str)
|
||||
}
|
||||
}
|
||||
|
||||
if (hHash) CryptDestroyHash(hHash);
|
||||
if (hCryptProv) CryptReleaseContext(hCryptProv, 0);
|
||||
if (hHash) ::CryptDestroyHash(hHash);
|
||||
if (hCryptProv) ::CryptReleaseContext(hCryptProv, 0);
|
||||
|
||||
return ret;
|
||||
#else
|
||||
|
Reference in New Issue
Block a user