freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

密碼學(xué)課程設(shè)計(jì)報(bào)告(文件加密解密系統(tǒng))(編輯修改稿)

2025-05-11 03:07 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 ER 1000includeiostreamincludebitsetinclude utilityusing namespace std。class AES {public: typedef unsigned char byte。 //static const int KEY_SIZE。//。 = 16。 // 密鑰長(zhǎng)度為位// static const int N_ROUND 。//= 11。 byte plainText[16]。 // 明文 byte state[16]。 // 當(dāng)前分組。 byte cipherKey[16]。 // 密鑰 byte roundKey[N_ROUND][16]。 //輪密鑰 byte cipherText[16]。 //密文 byte SBox[16][16]。 // S盒 byte InvSBox[16][16]。 // 逆S盒 void EncryptionProcess(){ // 加密過(guò)程 InitialState(plainText)。 KeyExpansion()。 // 密鑰擴(kuò)展 AddRoundKey(0)。 // 輪密鑰加 for(int i = 1。 i N_ROUND1。 ++i) { Round(i)。 } FinalRound()。 InitialCipherText()。}void DecryptionProcess(){ // 解密過(guò)程 InitialState(cipherText)。 KeyExpansion()。 InvFinalRound()。 for(int i = N_ROUND2。 i 0 。 i) { InvRound(i)。 } AddRoundKey(0)。 InitialplainText()。}void Round(const intamp。 round){ // 正常輪 SubBytes()。 ShiftRows()。 MixColumns()。 AddRoundKey(round)。 }void InvRound(const intamp。 round){ // 正常輪的逆 AddRoundKey(round)。 InvMixColumns()。 InvShiftRows()。 InvSubBytes()。 }void FinalRound(){ // 最后輪 SubBytes()。 ShiftRows()。 AddRoundKey(N_ROUND 1)。}void InvFinalRound(){ // 最后輪的逆 AddRoundKey(N_ROUND 1)。 InvShiftRows()。 InvSubBytes()。 }void KeyExpansion(){ // 密鑰擴(kuò)展 const byte rcon[N_ROUND][4] = { {0x00, 0x00, 0x00, 0x00}, {0x01, 0x00, 0x00, 0x00}, {0x02, 0x00, 0x00, 0x00}, {0x04, 0x00, 0x00, 0x00}, {0x08, 0x00, 0x00, 0x00}, {0x10, 0x00, 0x00, 0x00}, {0x20, 0x00, 0x00, 0x00}, {0x40, 0x00, 0x00, 0x00}, {0x80, 0x00, 0x00, 0x00}, {0x1b, 0x00, 0x00, 0x00}, {0x36, 0x00, 0x00, 0x00} }。 for(int ii = 0。 ii 16。 ++ii) { roundKey[0][ii] = cipherKey[ii]。 } for(int i = 0。 i 4。 ++i) { // roundKey[0][16]為cipherKey的轉(zhuǎn)置矩陣 for(int j = 0。 j 4。 ++j) { roundKey[0][4*i + j] = cipherKey[4*j + i]。 } } for(int roundIndex = 1。 roundIndex N_ROUND。 ++roundIndex) { byte rotWord[4] = {0x00}。 rotWord[0] = roundKey[roundIndex 1][3]。 rotWord[1] = roundKey[roundIndex 1][7]。 rotWord[2] = roundKey[roundIndex 1][11]。 rotWord[3] = roundKey[roundIndex 1][15]。 std::swapbyte(rotWord[0], rotWord[1])。 std::swapbyte(rotWord[1], rotWord[2])。 std::swapbyte(rotWord[2], rotWord[3])。 for(int i = 0。 i 4。 ++i) { rotWord[i] = SBox[ rotWord[i] 4][ rotWord[i] amp。 0x0f ]。 roundKey[roundIndex][4*i] = roundKey[roundIndex 1][4*i] ^ rotWord[i] ^ rcon[roundIndex][i]。 } for(int j = 1。 j 4。 ++j) { for(int i = 0。 i 4。 ++i) { roundKey[roundIndex][4*i + j] = roundKey[roundIndex 1][4*i + j] ^ roundKey[roundIndex][4*i + j 1]。 } } }}void AddRoundKey(const intamp。 round){ // 輪密鑰加 for(int i = 0。 i 16。 ++i) { // 利用當(dāng)前分組state和第round組擴(kuò)展密鑰進(jìn)行按位異或 state[i] ^= roundKey[round][i]。 }}void SubBytes(){ // 字節(jié)代換 for(int i = 0。 i 16。 ++i) { state[i] = SBox[ state[i] 4][ state[i] amp。 0x0f ]。 }}void InvSubBytes(){ // 逆字節(jié)代換 for(int i = 0。 i 16。 ++i) { state[i] = InvSBox[ state[i] 4][ state[i] amp。 0x0f ]。 }}void ShiftRows(){ // 行變換 //state第一行保持不變 // Do nothing. //state第二行循環(huán)左移一個(gè)字節(jié) std::swapbyte(state[4], state[5])。 std::swapbyte(state[5], state[6])。 std::swapbyte(state[6], state[7])。 //state第三行循環(huán)左移兩個(gè)字節(jié) std::swapbyte(state[8], state[10])。 std::swapbyte(state[9], state[11])。 //state第三行循環(huán)左移三個(gè)字節(jié) std::swapbyte(state[14], state[15])。 std::swapbyte(state[13], state[14])。 std::swapbyte(state[12], state[13])。 }void InvShiftRows(){ // 行變換反演 //state第一行保持不變 // Do nothing. //state第二行循環(huán)右移一個(gè)字節(jié) std::swapbyte(state[6], state[7])。 std::swapbyte(state[5], state[6])。 std::swapbyte(state[4], state[5])。 //state第三行循環(huán)右移兩個(gè)字節(jié) std::swapbyte(state[9], state[11])。 std::swapbyte(state[8], state[10])。 //state第三行循環(huán)右移三個(gè)字節(jié) std::swapbyte(state[12], state[13])。 std::swapbyte(state[13], state[14])。 std::swapbyte(state[14], state[15])。 }void MixColumns(){ // 列混淆 byte matrix[4][4] = { {0x02, 0x03, 0x01, 0x01}, {0x01, 0x02, 0x03, 0x01}, {0x01, 0x01, 0x02, 0x03}, {0x03, 0x01, 0x01, 0x02}}。 const byte* temp = GFMultplyBytesMatrix((byte*)matrix, state)。 for(int i = 0。 i 16。 ++i) { state[i] = temp[i]。 } // delete []temp。}void InvMixColumns(){ // 列混淆反演 byte matrix[4][4] = { {0x0e, 0x0b, 0x0d, 0x09}, {0x09, 0x0e, 0x0b, 0x0d}, {0x0d, 0x09, 0x0e, 0x0b}, {0x0b, 0x0d, 0x09, 0x0e} }。 const byte* temp = GFMultplyBytesMatrix((byte*)matrix, state)。 for(int i = 0。 i 16。 ++i) { state[i
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1