Window C/C++ Crypto API Examples and tips

前端 未结 3 537
不思量自难忘°
不思量自难忘° 2020-12-04 11:21

I\'m asking this question because I\'ve spent the best part of a day trawling through msdn docs and other opaque sources for simple straightforward guidelines on how to get

相关标签:
3条回答
  • 2020-12-04 12:05

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

    0 讨论(0)
  • 2020-12-04 12:06

    Here's a bunch of examples I've found....

    • Example C Program: Listing the Certificates in a Store
    • Example C Program: Using CryptAcquireContext
    • Example C Program: Enumerating CSP Providers and Provider Types
    • Example C Code for Opening Certificate Stores
    • Example C Program: Sending and Receiving a Signed and Encrypted Message
    • Example C Program: Signing a Hash and Verifying the Hash Signature

    MSDN has these examples scattered around the docs

    This website provides a good overview of the concepts along with cross-platform examples

    0 讨论(0)
  • 2020-12-04 12:14

    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.

    0 讨论(0)
提交回复
热议问题