[Go] Reference lib Static library in VS2010 VC + + project (for example, OpenSSL)

Source: Internet
Author: User
Tags sha256 algorithm

This article transferred from: http://kb.cnblogs.com/page/94467/

OpenSSL is a security protocol that provides security and data integrity for network communications, encompassing key cryptographic algorithms, common key and certificate encapsulation management functions, and SSL protocols, and provides a rich range of applications for testing or other purposes.

First download the OpenSSL package: (http://www.openssl.org/), this is a C language library package, under Windows can be makebuild through Perl to the class library, generating Libeay32, Ssleay32 Lib and DLL files, see: http://blogger.org.cn/blog/more.asp?name=OpenSSL&id=18972, compile to produce such a series of files:

Inc32 inside the C language header file.

1. Now I want to use it in VS2010 project, first I want to create a VC + +. NET project, I have created an MFC application here:

In the project name, click "Right", select "Properties", from the inside to find "VC + + Directory":

Two directory options found:

The directory that contains the directory pointing to your OpenSSL's header file, which points to your LIB, the directory where the DLL resides.

From here, create a new directory to point to the boot directory:

Then switch to "linker", "input":

In additional dependencies, add two lib files:

This completes the reference to the static library.

2. Now look at how to reference it in the project (take the SHA256 algorithm as an example):

#include <openssl/sha.h>

Methods Show:

?
1234567891011121314 // SHA256算法字符串加密void sha256(char* string, char outputBuffer[64]){    unsigned char hash[SHA256_DIGEST_LENGTH];    SHA256_CTX sha256;    SHA256_Init(&sha256);    SHA256_Update(&sha256, string, strlen(string));    SHA256_Final(hash, &sha256);    int i = 0;    for(i = 0; i < SHA256_DIGEST_LENGTH; i++)    {        sprintf(outputBuffer + (i * 2), "%02x", hash[i]);    }}

Call:

?
12 staticunsigned charbuffer[64];sha256(signature, (char*)buffer);

Since the OpenSSL package needs to be compiled using Perl to form Lib and DLL files, I enclose the files that have been made so that they can be used easily!

OpenSSL latest version of OPENSSL-1.0.0D's Windows execution Pack download: Openssl_out32dll.rar

[Go] Reference lib Static library in VS2010 VC + + project (for example, OpenSSL)

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.