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
- 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!