我想使用 Windows CryptoAPI 函数进行 AES 加密。
众所周知,API有很多功能可以创建、散列和更改输入的密钥;它派生出密钥,您就可以处理它。
我的问题是我想知道派生密钥是什么?
#include <Windows.h>
#include <stdio.h>
int main()
{
HCRYPTPROV hProv = 0;
HCRYPTKEY hKey = 0;
HCRYPTHASH hHash = 0;
DWORD dwCount = 5;
BYTE rgData[512] = {0x01, 0x02, 0x03, 0x04, 0x05};
LPWSTR wszPassword = L"pass";
DWORD cbPassword = (wcslen(wszPassword)+1)*sizeof(WCHAR);
if(!CryptAcquireContext(
&hProv,
NULL,
MS_ENH_RSA_AES_PROV,
PROV_RSA_AES,
CRYPT_VERIFYCONTEXT))
{
printf("Error %x during CryptAcquireContext!\n", GetLastError());
goto Cleanup;
}
if(!CryptCreateHash(hProv, CALG_SHA_256, 0, 0, &hHash))
{
printf("Error %x during CryptCreateHash!\n", GetLastError());
goto Cleanup;
}
if(!CryptHashData(hHash, (PBYTE)wszPassword, …Run Code Online (Sandbox Code Playgroud) 在 Macbook 上,我正在用 json-c( https://github.com/json-c/json-c )做一些事情
gcc a.c
a.c:1:10: fatal error: 'json.h' file not found
#include "json.h"
^
1 error generated.`>
Run Code Online (Sandbox Code Playgroud)
当我尝试编译它时,
它打印出错误,但我json.h在包含文件中有文件。
> cd /usr/local/include/json-c/
> ls
arraylist.h json_config.h json_tokener.h
bits.h json_inttypes.h json_util.h
debug.h json_object.h linkhash.h
json.h json_object_iterator.h printbuf.h
json_c_version.h json_object_private.h random_seed.h
Run Code Online (Sandbox Code Playgroud)
/usr/include/json-c/json.h 肯定存在
c ×2
aes ×1
cryptoapi ×1
cryptography ×1
encryption ×1
gcc ×1
header-files ×1
json ×1
json-c ×1