使用 msdn 在 CryptoApi 中创建 HMAC 的示例不起作用

问题描述

我正在尝试创建一个与 MSDN 站点显示的相同的 HMAC

https://docs.microsoft.com/ru-ru/windows/win32/seccrypto/example-c-program--creating-an-hmac?redirectedfrom=MSDN

我只是复制了代码并运行了编译命令

g++ hmac_create.c -o result

我得到编译错误

    error: 'CALG_HMAC' undeclared (first use in this function); did you mean 'CALG_MAC'?
  115 |     CALG_HMAC,// HMAC hash algorithm ID
      |     ^~~~~~~~~
      |     CALG_MAC
h.c:115:5: note: each undeclared identifier is reported only once for each function it appears in

如果我们用 CALG_MAC 替换 CALG_HMAC,那么编译成功完成,但运行文件我仍然得到一个错误

Error in CryptCreateHash 0x80090003

我该怎么办?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)