Files
energy_storage/src/common/Crypto.h
2025-09-20 16:41:08 +08:00

38 lines
844 B
C++

#ifndef _Crypto_H_
#define _Crypto_H_
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string>
#include <gmssl/sm4.h>
#include <gmssl/hex.h>
#include <gmssl/sm2.h>
using namespace std;
class Crypto
{
public:
static string md5(string src);
/**
* @brief SM4-ECB 加密示例
* @param key 16字节密钥
* @param plaintext 明文数据
* @return 密文字节向量
*/
static std::vector<uint8_t> sm4EcbEncrypt(const std::vector<uint8_t>& key, const std::vector<uint8_t>& plaintext);
/**
* @brief SM4-ECB 解密示例
* @param key 16字节密钥
* @param ciphertext 密文数据
* @return 明文字节向量
*/
static std::vector<uint8_t> sm4EcbDecrypt(const std::vector<uint8_t>& key, const std::vector<uint8_t>& ciphertext);
};
#endif // ! _Crypto_H_