我已经在工程-设置-link中添加了libeay32.dll,怎么编译过程中还是出现这个错误?程序如下:
// EVP_Encrypt.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <openssl/evp.h>
#include <openssl/x509.h>
void tEVP_Encrypt()
{
unsigned char key[EVP_MAX_KEY_LENGTH]; //密钥
unsigned char iv[EVP_MAX_KEY_LENGTH]; //初始化向量
EVP_CIPHER_CTX ctx; //EVP算法上下文
unsigned char out[1024]; //输出密文缓冲区
int outl; //密文长度
int outltmp;
char *msg="Hello OpenSSL"; //待加密的数据
int rv;
int i; //设置key和iv(可以采用随机数,也可以由用户输入)
for(i=0;i<24;i++)
{
key[i]=i;
}
for(i=0;i<8;i++)
{
iv[i]=i;
} //初始化密码算法结构体
EVP_CIPHER_CTX_init(&ctx); //设置算法和密钥以及初始化向量
rv=EVP_EncryptInit_ex(&ctx,EVP_des_ede3_cbc(),NULL,key,iv);
if(rv!=1)
{
printf("ERR\n");
return;
} //数据加密
rv=EVP_EncryptUpdate(&ctx,out,&outl,(const unsigned char *)msg,strlen(msg));
if(rv!=1)
{
printf("ERR\n");
return;
} //结束数据加密,把剩余数据输出
rv=EVP_EncryptFinal_ex(&ctx,out+outl,&outltmp);
if(rv!=1)
{
printf("ERR\n");
return;
}
outl=outl+outltmp;
printf("原文为:%s\n",msg); //打印输出密文
printf("密文长度:%d\n 密文数据: \n",outl);
for(i=0;i<outl;i++)
{
printf("0x%02x",out[i]);
}
printf("\n");
}
int main()
{
OpenSSL_add_all_algorithms();
tEVP_Encrypt();
return 0;
}
// EVP_Encrypt.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <openssl/evp.h>
#include <openssl/x509.h>
void tEVP_Encrypt()
{
unsigned char key[EVP_MAX_KEY_LENGTH]; //密钥
unsigned char iv[EVP_MAX_KEY_LENGTH]; //初始化向量
EVP_CIPHER_CTX ctx; //EVP算法上下文
unsigned char out[1024]; //输出密文缓冲区
int outl; //密文长度
int outltmp;
char *msg="Hello OpenSSL"; //待加密的数据
int rv;
int i; //设置key和iv(可以采用随机数,也可以由用户输入)
for(i=0;i<24;i++)
{
key[i]=i;
}
for(i=0;i<8;i++)
{
iv[i]=i;
} //初始化密码算法结构体
EVP_CIPHER_CTX_init(&ctx); //设置算法和密钥以及初始化向量
rv=EVP_EncryptInit_ex(&ctx,EVP_des_ede3_cbc(),NULL,key,iv);
if(rv!=1)
{
printf("ERR\n");
return;
} //数据加密
rv=EVP_EncryptUpdate(&ctx,out,&outl,(const unsigned char *)msg,strlen(msg));
if(rv!=1)
{
printf("ERR\n");
return;
} //结束数据加密,把剩余数据输出
rv=EVP_EncryptFinal_ex(&ctx,out+outl,&outltmp);
if(rv!=1)
{
printf("ERR\n");
return;
}
outl=outl+outltmp;
printf("原文为:%s\n",msg); //打印输出密文
printf("密文长度:%d\n 密文数据: \n",outl);
for(i=0;i<outl;i++)
{
printf("0x%02x",out[i]);
}
printf("\n");
}
int main()
{
OpenSSL_add_all_algorithms();
tEVP_Encrypt();
return 0;
}
解决方案 »
- 关于stl中容器中使用的字符串类型
- cannot open file "libpcap.lib"..
- MFC 基于对话框 OnPaint()显示信息
- 通过函数如何传出动态结构数组?
- 如何在一个Form中嵌入另一个程序?
- opencv旋转后图怎么不被切掉跟怎么不扩边,图的数据又是怎么放到BYTE*里
- 怎么我给static添加BN_CLICKED事件,在它里面写代码,它不响应啊?我调试的时候根本就不进去
- 有人读过CSplitterWnd类的原码吗?大家来讨论(讨论又分)
- 我在VC中用ADO编程操作数据库中的image字段,存的时候没有问题,读的时候却有问题?
- 线程紧急求助
- 关于MFC结构的一个简单问题
- 编码函数ICOpen始终返回零,帮忙看看
link选项要要添加的是lib文件,看看有没有libeay32.lib,如果没有,就只能用LoadLibrary、GetProcAddress的方式动态链接dll了。
现在编译通过了,执行的时候,说找不到这个libeay32.dll文件了。