代码
- 使用md5对于用户输入的密码进行保护,也使得密码的长度固定
- crypto_util.h
#pragma once
#include <string>
namespace hsm{
namespace mgmt{
void get_md5_digest(const std::string &data,uint8_t result[16]);
void aes_encrypt_to_file(const std::string &file_name,
const std::string &password,const std::string &data);
std::string aes_decrypt_from_file(const std::string &file_name,
const std::string &password);
}//namespace mgmt
}//namespace hsm
#include "crypto_util.h"
#include <cstring>
#include <fstream>
#include <memory>
#include <sstream>
#include <openssl/aes.h>
#include <openssl/md5.h>
namespace hsm{
namespace mgmt{
void get_m