1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
HCRYPTPROV ctx;
HCRYPTHASH hash;
HCRYPTKEY key;
char data[32] = "Some data";
DWORD len = strlen(data);
CryptAcquireContext(&ctx, 0, "Microsoft Base Cryptographic Provider v1.0", 1, CRYPT_VERIFYCONTEXT);
CryptCreateHash(ctx, CALG_MD5, 0, 0, &hash);
CryptHashData(hash, "mykey", 5, 0);
CryptDeriveKey(ctx, CALG_RC4, hash, 4, &key);
CryptDecrypt(key, 0, 0, 0, (BYTE *)data, &len);
CryptDestroyKey(key);
CryptDestroyHash(hash);
CryptReleaseContext(ctx);
|