Files
energy_storage/src/common/Crypto.h

38 lines
844 B
C
Raw Normal View History

2025-09-20 16:41:08 +08:00
#ifndef _Crypto_H_
#define _Crypto_H_
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string>
2025-09-20 16:41:08 +08:00
#include <gmssl/sm4.h>
#include <gmssl/hex.h>
#include <gmssl/sm2.h>
using namespace std;
class Crypto
{
public:
static string md5(string src);
2025-09-20 16:41:08 +08:00
/**
* @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_