J'ai ça en C++ :
#define WIN32_LEAN_AND_MEAN
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <wincrypt.h>
#include <stdio.h>
char* GenericHash(unsigned int AlgId,char* Buffer, int lBuffer)
{
HCRYPTPROV hProv; HCRYPTHASH hHash;
BYTE* Hash; DWORD lHash, len;
if (CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET))
{
if (CryptCreateHash(hProv,AlgId,0,0,&hHash))
{
if (CryptHashData(hHash,(BYTE*)Buffer,lBuffer,0))
{
if (CryptGetHashParam(hHash,HP_HASHSIZE,(BYTE*)&lHash,&len,0))
{
Hash = new BYTE[lHash];
if (!Hash) return NULL;
if (!CryptGetHashParam(hHash,HP_HASHVAL,Hash,&lHash,0))
{
delete[] Hash;
return NULL;
}
}
}
else return NULL;
}
else return NULL;
}
else return NULL;
CryptDestroyHash(hHash);
CryptReleaseContext(hProv,0);
char* sHash = new char[lHash*2+1]; memset(sHash,0,lHash*2+1);
for (unsigned char i = 0; i <= lHash-1; i++)
{
sprintf(sHash+(i*2),"%02X",Hash[i]);
}
delete[] Hash;
return sHash;
}
VB.NET is good ... VB6 is better !