Parsing Lua calls the C ++ certificate encryption and decryption file function implementation

Source: Internet
Author: User

LuaCallC ++ CertificateEncryption and decryptionFileFunction implementation is the content to be introduced in this article. The success of recent studies has finally come to some results, and it has been basically implemented using C ++.CertificateEncryption and decryptionFile. It mainly uses the methods provided in the window API Cryptography to encrypt and decrypt certificates.

CertificateMainly to find the certificate library of Window (Certificate fileImport it to IE). Here I use the CertOpenStore function to open MY certificate library (this can be another value, depending on your needs, for details, you can find this method in MSDN), and then use the CertFindCertificateInStore function to find the Certificate in MY certificate library (this method has a parameter that needs to be specified with the Certificate Name, parameter name: pvFindPara), if you find the specified certificate in MY certificate library, you can perform encryption, decryption, and other operations. Here we will not talk about it much. For details, refer to the subsequent code. For specific environment configuration, see my previous blog.

You also need to configure the Peoject encoding.

Specific configuration: Right-click

 
 
  1. Project->property->Configuration Properties->General->Project Defaults->Character Set  

Select Use Unicode Character Set and Set the Project to unicode encoding.

For specific code, see the source code in the attachment, which contains comments!

Example environment: Visual C ++ 2008 Express Edition + Lua5.1 + SciTE (with Lua installed)

Attachment introduction (open with Visual C ++ 2008 ):

1. There are two projects in the attachment: unicode and crypto.

2. To run this example, you must Build both unicode and crypto projects.

3. copy the unicode. dll and crypto. dll files to the lua file at the same level under the Debug directory of the current Project.

4. Use SciTE to open the. Lua file in the lua folder in the attachment and modify the Certificate Name. If you do not know the certificate name, you can choose IE> Tools> Internet Options> content> certificates> individuals (only individuals can be, because L "MY" is written to the program, double-click the certificate you want to use, open the dialog box, you can see "issued to", or go to the details-> topic, the following CN is the certificate name.

5. Run lua

If youCertificateThere is a certificate in the database. If the certificate name is correct, you can see the encrypted and decrypted files.

Summary: AnalysisLuaCallC ++ CertificateEncryption and decryptionFileThe function implementation is complete. I hope this article will help you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.