Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti qarshi filiali
Download 0.97 Mb.
|
lab4
Дастур коди. //--------------------------------------------------------------------------- #include #include "function_AES.h" #pragma hdrstop #include "Unit1.h" #include "Unit2.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm2 *Form2; //--------------------------------------------------------------------------- __fastcall TForm2::TForm2(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm2::Button2Click(TObject *Sender) { Form2->Hide(); Form1->Show(); } //--------------------------------------------------------------------------- void __fastcall TForm2::Button1Click(TObject *Sender) { String s,s1,m1,m2,m3,m4,m5,m6,m7; String k[4][4],k1[4][4]; s=Edit1->Text; int h=1; for(int i=0;i<4;i++){ for(int j=0;j<4;j++) { k[i][j]=s[h]; h+=1; k[i][j]+=s[h]; h+=1; m6+=k[i][j]; } m6+="\n"; } m6+="\n"; String rcon[10]={"01","02","04","08","10","20","40","80","16","36"}; for(int i=0;i<10;i++) m4+=rcon[i]+"000000\n\n\n\n\n"; for(int g=0;g<10;g++){ for(int i=0;i<4;i++) {k1[0][i]=k[3][i]; m1+=k1[0][i]; } String tmp; tmp=k1[0][0]; k1[0][0]=k1[0][1]; k1[0][1]=k1[0][2]; k1[0][2]=k1[0][3]; k1[0][3]=tmp; for(int i=0;i<4;i++) { m2+=k1[0][i]; tmp=k1[0][i]; k1[0][i]=sub_bytes(tmp[1],tmp[2]); m3+=k1[0][i]; } m2+="\n\n\n\n"; m3+="\n\n\n\n"; k1[0][0]=xor(k1[0][0],rcon[g]); for(int i=0;i<4;i++) { m5+=k1[0][i]; k1[0][i]=xor(k1[0][i],k[0][i]); m7+=k1[0][i]; m6+=k1[0][i]; } m5+="\n\n\n\n"; m7+="\n"; m6+="\n"; for(int i=1;i<4;i++){ for(int j=0;j<4;j++){ k1[i][j]=xor(k1[i-1][j],k[i][j]); m7+=k1[i][j]; m6+=k1[i][j]; } m7+="\n"; m6+="\n"; } for(int i=0;i<4;i++){ for(int j=0;j<4;j++){ k[i][j]=k1[i][j]; } }
for(int i=0;i<3;i++){ for(int j=0;j<4;j++){ m1+=k[i][j]; } m1+="\n"; } m1+="\n"; m2+="\n"; m3+="\n"; m4+="\n"; m5+="\n"; m6+="\n"; m7+="\n"; } Memo6->Lines->Text=m6; Memo1->Lines->Text=m1; Memo2->Lines->Text=m2; Memo3->Lines->Text=m3; Memo4->Lines->Text=m4; Memo5->Lines->Text=m5; Memo7->Lines->Text=m7; } //--------------------------------------------------------------------------- Шифрлаш жараѐни. Дешифрлаш жараѐни . Download 0.97 Mb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling