代码拉取完成,页面将自动刷新
#ifndef AES_H
#define AES_H
/**************************************************
* project name: AES
* author: wang binbin
* completion time: 2024.3.26
*************************************************/
#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<iomanip>
#include<cstdio>
#include<bitset>
#include<stack>
#include<cmath>
#include<random>
#include<ctime>
using namespace std;
#define NUMBER 16
#define SECRET_KEY_PATH "key.txt"
class AES
{
public:
AES();
// Generate a random key
void genKey(std::string outputname);
// Get key
void getKey(const std::string filename);
// AES encryption
void encrypt(int ptext[4][4]);
// AES decryption
void decrypt(int ctext[4][4]);
// Encrypt the file
bool encrypt_file(const std::string filename, const std::string outname);
// Decrypt the file
bool decrypt_file(const std::string filename, const std::string outname);
private:
std::string Key;
// Generating S-box
void genSbox(int box[16][16]);
// Generating inverse S-box
void genSbox2(int box[16][16]);
// Multiplication over finite fields
int gfMul(int n, int m);
// Find inverses over finite fields
int invElement(int m);
// Byte move
void leftByte(int word[4]);
// G function for MixColumn
void gFunction(int word[4], int round);
// key expansion
void keyExpansion(int word[4][44]);
// Byte conversion
void subBytes(int m[4][4]);
// Inverse byte conversion
void subBytes2(int m[4][4]);
// Row shift
void shiftRow(int m[4][4]);
// Inverse row shift
void shiftRow2(int m[4][4]);
// Column mix
void mixColumn(int m[4][4]);
// Inverse column mix
void mixColumn2(int m[4][4]);
// RoundKey Add
void addRoundKey(int m[4][4], int key[4][4]);
// Integer to hexadecimal
std::string intToHex(int value);
// Hexadecimal to integer
int hexToInt(const std::string& hexStr);
};
#endif // AES_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。