Window C/C++ Crypto API Examples and tips

雨燕双飞 提交于 2019-11-27 17:32:14
Gearoid Murphy

The msdn docs are here: http://msdn.microsoft.com/en-us/library/aa380252.aspx

This is the main include file: #include <wincrypt.h>

The cryptography bits are included as part of the Windows SDK, which is typically installed in %PROGRAMFILES(x86)%\Microsoft SDKs\Windows\SDKVERSION (e.g., C:\Program Files\Microsoft SDKs\Windows\v6.0A). The headers are typically in %WINDOWSSDK%\Include, and the related libraries are in %WINDOWSSDK%\Lib.

You must link to the cryptography libraries explicitly. Assuming you're in Visual Studio, you can add the reference by right clicking on the C++ project, choosing properties, and selecting Configuration Properties -> Linker on the treeview at left. You can then specify crypt32.lib in the input field on the right.

Alternately, (assuming you're using msvc++) add

#pragma comment(lib, "crypt32.lib")

to your source.

There is also a lengthy example "Encryption using the Win32 Crypto API" over at the Code Project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!