openssl安装 (Ubuntu)
openssl
传输层安全性/安全套接层及其加密库
项目地址:https://gitcode.com/gh_mirrors/ope/openssl
免费下载资源
·
使用以下这两个头文件
#include <openssl/aes.h>
#include <openssl/evp.h>
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install libssl-doc
1、sudo apt-get install openssl
2、 sudo apt-get install libssl-dev
3、sudo apt-get install libssl-doc
4、解密和解密的接口
//编译时,注意加入 -lssl -lcrypto
// gcc .... -lssl -lcrypto
#include <stdio.h>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include <string.h>
#include "securityCode.h"
//编译时,注意加入 -lssl -lcrypto
// gcc .... -lssl -lcrypto
// 加密函数
void encrypt(const unsigned char *plaintext, int plaintext_len, const unsigned char *key,
const unsigned char *iv, unsigned char *ciphertext) {
EVP_CIPHER_CTX *ctx;
int len;
int ciphertext_len;
ctx = EVP_CIPHER_CTX_new();
EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv);
EVP_EncryptUpdate(ctx, ciphertext, &len, plaintext, plaintext_len);
ciphertext_len = len;
EVP_EncryptFinal_ex(ctx, ciphertext + len, &len);
ciphertext_len += len;
EVP_CIPHER_CTX_free(ctx);
}
// 解密函数
void decrypt(const unsigned char *ciphertext, int ciphertext_len, const unsigned char *key,
const unsigned char *iv, unsigned char *plaintext) {
EVP_CIPHER_CTX *ctx;
int len;
int plaintext_len;
ctx = EVP_CIPHER_CTX_new();
EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv);
EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len);
plaintext_len = len;
EVP_DecryptFinal_ex(ctx, plaintext + len, &len);
plaintext_len += len;
EVP_CIPHER_CTX_free(ctx);
}
GitHub 加速计划 / ope / openssl
25.12 K
9.99 K
下载
传输层安全性/安全套接层及其加密库
最近提交(Master分支:1 个月前 )
fd39d1c8
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/25095)
1 个月前
ae87c488
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/25095)
1 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)