电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

C++的AES代码

C++的AES代码_第1页
1/14
C++的AES代码_第2页
2/14
C++的AES代码_第3页
3/14
AES 加密算法 C++的 AES 代码(转) 在 VC7.1 下编译调试成功,下面是源代码 //AES.H #pragma once class AES { public: typedef enum ENUM_KeySize_ { BIT128 = 0, BIT192, BIT256 }ENUM_KEYSIZE; public: AES( ENUM_KEYSIZE keysize, BYTE *key ); ~AES(void); void Cipher( BYTE *input, BYTE *output ); void InvCipher( BYTE *input, BYTE *output ); protected: BYTE *RotWord( BYTE *word ); BYTE *SubWord( BYTE *word ); void AddRoundKey(int round); void SubBytes(); void InvSubBytes(); void ShiftRows(); void InvShiftRows(); void MixColumns(); void InvMixColumns(); static BYTE gfmultby01(BYTE b) { return b; } static BYTE gfmultby02(BYTE b) { if (b < 0x80) return (BYTE)(int)(b <<1); else return (BYTE)( (int)(b << 1) ^ (int)(0x1b) ); } static BYTE gfmultby03(BYTE b) { return (BYTE) ( (int)gfmultby02(b) ^ (int)b ); } static BYTE gfmultby09(BYTE b) { return (BYTE)( (int)gfmultby02(gfmultby02(gfmultby02(b))) ^ (int)b ); } static BYTE gfmultby0b(BYTE b) { return (BYTE)( (int)gfmultby02(gfmultby02(gfmultby02(b))) ^ (int)gfmultby02(b) ^ (int)b ); } static BYTE gfmultby0d(BYTE b) { return (BYTE)( (int)gfmultby02(gfmultby02(gfmultby02(b))) ^ (int)gfmultby02(gfmultby02(b)) ^ (int)(b) ); } static BYTE gfmultby0e(BYTE b) { return (BYTE)( (int)gfmultby02(gfmultby02(gfmultby02(b))) ^ (int)gfmultby02(gfmultby02(b)) ^ (int)gfmultby02(b) ); } int Nb; int Nk; int Nr; BYTE *key;// the seed key. size will be 4 * keySize from ctor. typedef struct BYTE4_ { BYTE w[4]; }BYTE4; BYTE4 *w; LPBYTE State[4]; /* private byte[,] iSbox; // inverse Substitution box private byte[,] w; // key schedule array. private byte[,] Rcon; // Round constants. private byte[,] State; // State matrix*/ }; //AES.CPP #include "StdAfx.h" #include ".\aes.h" const BYTE Sbox[16][16] = { // populate the Sbo...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部