谁知道哪里有AES算法加密,解密c++⼀C语言代码?

求AES算法加密,解密c++/C语言代码
2025-02-25 02:31:45
推荐回答(4个)
回答1:

我有写好的,肿么给你?贴上来吧。

#ifndef aes_h_
#define aes_h_

#include
#include

using namespace std;

typedef unsigned char uint8;

class aes
{
public:
/// 构造函数
aes();

/// 析构函数
~aes();

/// 加密,默认256位密码
///
/// @param input 要加密的字符串
/// @param output 加密后字符串
/// @return 无
/// @see
/// @note (note描述需要注意的问题)
void encrypt(const string& input, string& output);

/// 解密 默认密码
///
/// @param input 要解密字符串
/// @param output 解密后字符串
/// @return 无
/// @see
/// @note (note描述需要注意的问题)
void decrypt(const string& input, string& output);

/// 加密 256位
///
/// @param key 密码
/// @param input 要加密的字符串
/// @param output 加密后字符串
/// @return 无
/// @see
/// @note (note描述需要注意的问题)
void encrypt(uint8 key[32], const string& input, string& output);

/// 解密 256位
///
/// @param key 密码
/// @param input 要解密字符串
/// @param output 解密后字符串
/// @return 无
/// @see
/// @note (note描述需要注意的问题)
void decrypt(uint8 key[32],const string& input, string& output);

private:
typedef struct
{
uint32 erk[64]; /* encryption round keys */
uint32 drk[64]; /* decryption round keys */
int nr; /* number of rounds */
}aes_context;

int aes_set_key( aes_context* ctx, uint8* key, int nbits );
void aes_encrypt( aes_context* ctx, uint8 input[16], uint8 output[16] );
void aes_decrypt( aes_context* ctx, uint8 input[16], uint8 output[16] );

};

#endif // aes_h_

我晕,太长贴不上来啊?

回答2:

推荐用java,因为有现成的class给你用。。。如果用C++有好多东西需要自己写。可能java里面20行能搞定加密和解密的所有步骤,如果C++自己把所有算法加上各种数据类型转换之类的,无法估计多多少倍的代码了。前提还是你已经会写如果做密钥。

回答3:


你可以进去看下

回答4:


你可以进去看下
另外,站长团上有产品团购,便宜有保证