有时您必须实现 C 代码和加密,所以我的 hmac256 或 sha2_hmac 实现的 C 代码实现存在问题:
unsigned char key[19] = { "abcdef" };
size_t keylen = 18;
unsigned char input[64] = {"123456789"};
size_t ilen = 63;
unsigned char output[32];
int is224 = 0;
sha2_hmac(key, keylen, input, ilen, output, is224);
char result[64] = {};
char result2[64] = {};
for(int j = 0; j < 32; j++) {
sprintf(result, "%X", output[j]);
strcat(result2, result);
}
但是当我将它与 C# 代码进行比较时,结果太短了。