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

正文內(nèi)容

信息安全實驗報告des加密算法-資料下載頁

2025-08-03 09:31本頁面
  

【正文】 48]。 if((plain = fopen(plainFile,rb)) == NULL){ return PLAIN_FILE_OPEN_ERROR。 } if((cipher = fopen(cipherFile,wb)) == NULL){ return CIPHER_FILE_OPEN_ERROR。 } //設(shè)置密鑰 memcpy(keyBlock,keyStr,8)。 //將密鑰轉(zhuǎn)換為二進制流 Char8ToBit64(keyBlock,bKey)。 //生成子密鑰 DES_MakeSubKeys(bKey,subKeys)。 while(!feof(plain)){ //每次讀8個字節(jié),并返回成功讀取的字節(jié)數(shù) if((count = fread(plainBlock,sizeof(char),8,plain)) == 8){ DES_EncryptBlock(plainBlock,subKeys,cipherBlock)。 fwrite(cipherBlock,sizeof(char),8,cipher)。 } } if(count){ //填充 memset(plainBlock + count,39。\039。,7 count)。 //最后一個字符保存包括最后一個字符在內(nèi)的所填充的字符數(shù)量 plainBlock[7] = 8 count。 DES_EncryptBlock(plainBlock,subKeys,cipherBlock)。 fwrite(cipherBlock,sizeof(char),8,cipher)。 } fclose(plain)。 fclose(cipher)。 return OK。 } //解密文件 int DES_Decrypt(char *cipherFile, char *keyStr,char *plainFile){ FILE *plain, *cipher。 int count,times = 0。 long fileLen。 ElemType plainBlock[8],cipherBlock[8],keyBlock[8]。 ElemType bKey[64]。 ElemType subKeys[16][48]。 if((cipher = fopen(cipherFile,rb)) == NULL){ return CIPHER_FILE_OPEN_ERROR。 } if((plain = fopen(plainFile,wb)) == NULL){ return PLAIN_FILE_OPEN_ERROR。 } //設(shè)置密鑰 memcpy(keyBlock,keyStr,8)。 //將密鑰轉(zhuǎn)換為二進制流 Char8ToBit64(keyBlock,bKey)。 //生成子密鑰 DES_MakeSubKeys(bKey,subKeys)。 //取文件長度 fseek(cipher,0,SEEK_END)。 //將文件指針置尾 fileLen = ftell(cipher)。 //取文件指針當前位置 rewind(cipher)。 //將文件指針重指向文件頭 while(1){ //密文的字節(jié)數(shù)一定是8的整數(shù)倍 fread(cipherBlock,sizeof(char),8,cipher)。 DES_DecryptBlock(cipherBlock,subKeys,plainBlock)。 times += 8。 if(times fileLen){ fwrite(plainBlock,sizeof(char),8,plain)。 } else{ break。 } } //判斷末尾是否被填充 if(plainBlock[7] 8){ for(count = 8 plainBlock[7]。 count 7。 count++){ if(plainBlock[count] != 39。\039。){ break。 } } } if(count == 7){//有填充 fwrite(plainBlock,sizeof(char),8 plainBlock[7],plain)。 } else{//無填充 fwrite(plainBlock,sizeof(char),8,plain)。 } fclose(plain)。 fclose(cipher)。 return OK。 } int main() { DES_Encrypt(,)。 //, ,system(pause)。 DES_Decrypt(,)。 getchar()。 return 0。 } 五、實驗結(jié)果總結(jié)運行結(jié)果如下:心得: (1) 通過本次實驗我學(xué)會了用DES加密算法加密和解密。對一連串的代碼有了一定的了解與認識,能夠通過代碼認識加解密的過程。通過用DES算法對實際數(shù)據(jù)進行加密和解密深刻了解了DES的運行原理,進而加深了對對稱加密算法的理解與認識。(2)通過這次結(jié)合實際解決加解密的過程,認識很深刻,感覺到了DES的重要性。13
點擊復(fù)制文檔內(nèi)容
語文相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1