openssl linux下编译
git checkout OpenSSL_1_1_1两下tab健,确定最新版本为OpenSSL_1_1_1q
git clone https://github.com/openssl/openssl.git
git checkout OpenSSL_1_1_1q
输出到当前目录下的output目录
./config --prefix=`pwd`/output
make -j 6
make install
当前目录下的output目录就是最终生成的文件,复制output/include和output/lib/libssl.so,output/lib/libcrypto.so 到本地代码目录
openssl hmac加密,使用dlopen防止和系统的so干扰
#include <stdio.h>
#include <string.h>
#include <dlfcn.h>
#include <openssl/hmac.h>
#include <openssl/opensslv.h>
#include <openssl/crypto.h> // unsigned long SSLeay(void)
int main(int argc,void **argv) {
//key value
const char key[] = "key-abcd";
//data in hex, /or you can init with text
unsigned char data[] = "12345";
unsigned char result[20] = {
0};
unsigned int resultlen = 20;
void *handleCrypto = dlopen("./libcrypto.so", RTLD_LAZY | RTLD_DEEPBIND);
if(handleCrypto == NULL)
{