小编use*_*230的帖子

OpenSSL AES_cfb128_encrypt C++

我试图实现一个"非常"简单的加密/解密示例.我需要一个项目,我想加密一些用户信息.我无法加密整个数据库,只能加密表中的某些字段.

除了加密之外,数据库和项目的大部分工作都有效:以下是它的简化版本:

#include <openssl/aes.h>
#include <openssl/evp.h>
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    /* ckey and ivec are the two 128-bits keys necessary to
       en- and recrypt your data.  Note that ckey can be
       192 or 256 bits as well
     */

    unsigned char ckey[] =  "helloworldkey";
    unsigned char ivec[] = "goodbyworldkey";

    int bytes_read;
    unsigned char indata[AES_BLOCK_SIZE];
    unsigned char outdata[AES_BLOCK_SIZE];
    unsigned char decryptdata[AES_BLOCK_SIZE];

    /* data structure that contains the key itself */
    AES_KEY keyEn;

    /* set the encryption …
Run Code Online (Sandbox Code Playgroud)

c++ encryption openssl aes

4
推荐指数
1
解决办法
4702
查看次数

标签 统计

aes ×1

c++ ×1

encryption ×1

openssl ×1