




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、信息安全排列碼編程實(shí)現(xiàn)(Information security permutation code programming implementation)/ * n = 4 permutation source program c + + programming * /# include # include Int reverse (int); / / inverse functionVoid encode (); / / encryption functionVoid decode (); / / decryption functionInt a 8, c 8, 16 d, e, f 4,
2、8 remainder;/ / the main functionInt main ()Char bite0 bite1, bite4 bite5, key0 4, the key 12, zkey 12.File_name2 char file_name1 200, 200, file_name3 200, file_name4 200.Int I, j, k, choose, zijie2 = 0, zijie3 = 0;Choose the operation you want: - - - - - - - - - - - - - - - - - - - - - - - - - - -
3、- -Please press 1 button for the encrypted file. endl;Please press 2 for the decryption file. endl;Cout to exit please press 3. endl;Cout - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;Cout choose;/ / encryption processIf (choose = = 1)Cout enter the file name and its path to be
4、 encrypted: endl;Cout file_name1;The file name and its path to be saved after encryption: endl;Cout file_name2;Ifstream fs0 (file_name1, the ios: : binary);If (! Fs0)Cout file open failed! endl;Return 1;Ofstream fs1 (file_name2, the ios: : binary);If (! Fs1)Cout file open failed! endl;Return 1;Cout
5、enter your 4-bit key endl key0;While (fs0. Get (bite0)For (I = 0; I 1;For (k = 0; k 12; k+)The key k = key0 (k + 4) / 4;For (j = 0; j 12; j+)Zkey j = key j;For (I = 0; I 10; I = I + 3)/ / mod 24The remainder = key I 0 + % 24;/ / see which path needs to be reversed, the first eight pathsFor (j = 0; j
6、 1;/ / eight pathsFor (j = 8; j 1;Encode ();For (j = 0; j 4; j+)E j = j;For (j = 0; j 4; j+)C = c + 4 j j;Encode ();For (j = 0; j 4; j+)E = a + 4 j j;For (j = 0; j = 0; j -)Zijie2 = zijie2 1;Zijie2 = zijie2 | c j;Bite4 = char (zijie2);Fs1. Put (bite4);For (j = 0; j 12; j+)The key j = zkey j;Fs0. Clo
7、se ();Fs1. Close ();/ / cout = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = endl ;/ / decryption processIf (choose = = 2)The name of the file to be decrypted and its path: endl;Cout file_name3;The file name and its path to be saved after decryption: endl;Cout file_name4;
8、Ifstream fs2 (file_name3, the ios: : binary);If (! Fs2)Cout file open failed! endl;Return 1;Ofstream fs3 (file_name4, the ios: : binary);If (! Fs3)Cout file open failed! endl;Return 1;Cout enter your four decryption key (same as the encryption key) : endl;Cout key0;/ / cout = = = = = = = = = = = = =
9、 = = = = = = = = = = = = = = = = = = = = = = = = = endl ;While (fs2. Get (bite1)For (I = 0; I 1;For (k = 0; k 12; k+)The key k = key0 (k + 4) / 4;For (j = 0; j = 0; I = I - 3)/ / mod 24The remainder = key I 0 + % 24;/ / see which path needs to be reversed, the first eight pathsFor (j = 0; j 1;/ / ei
10、ght pathsFor (j = 8; j 1;Decode ();For (j = 0; j 4; j+)E = f j j;For (j = 0; j 4; j+)A j = a + 4 j;Decode ();For (j = 0; j 4; j+)E = f + 4 j j;For (j = 0; j = 0; j -)Zijie3 = zijie3 1;Zijie3 = zijie3 | a, j.Bite5 = char (zijie3);Fs3. Put (bite5);For (j = 0; j 12; j+)The key j = zkey j;Fs2. Close ();
11、Fs3. Close ();If (choose = = 3)Its over. endl;Cout - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - endl ;Return 0;/ / inverse functionInt reverse (int x)X = x;X = x & 1;Return the x;The permutation table used in the encryption functionVoid encode ()開(kāi)關(guān)(剩余部分)例0:/ / 3 2 1 0一個(gè)0= c3
12、;如果(d12= = 1)0=反向(0);c1=2;如果(d9= = 1)1=反向(1);2= c1;如果(d6= = 1)2=反向(2);3= c0;如果(d3= = 1)3=反向(3);打破;案例1:/ / 3 2 0 1一個(gè)0= c2;如果(d8= = 1)0=反向(0);c1=3;如果(d13= = 1)1=反向(1);2= c1;如果(d6= = 1)2=反向(2);3= c0;如果(d3= = 1)3=反向(3);打破;情形2:/ / 3 1 2 0一個(gè)0= c3;如果(d12= = 1)0=反向(0);1= c1;如果(d5= = 1)1=反向(1);2= c2;如果(d10=
13、= 1)2=反向(2);3= c0;如果(d3= = 1)3=反向(3);打破;案例3:/ / 3 1 0 2一個(gè)0= c2;如果(d8= = 1)0=反向(0);1= c1;如果(d5= = 1)1=反向(1);2= c3;如果(d14= = 1)2=反向(2);3= c0;如果(d3= = 1)3=反向(3);打破;案例4:/ / 3 0 2 1一個(gè)0= c1;如果(d4= = 1)0=反向(0);c1=3;如果(d13= = 1)1=反向(1);2= c2;如果(d10= = 1)2=反向(2);3= c0;如果(d3= = 1)3=反向(3);打破;案例5:/ / 3 0 1 2一個(gè)0
14、= c1;如果(d4= = 1)0=反向(0);c1=2;如果(d9= = 1)1=反向(1);2= c3;如果(d14= = 1)2=反向(2);3= c0;如果(d3= = 1)3=反向(3);打破;案例6:/ / 2 3 1 0一個(gè)0= c3;如果(d12= = 1)0=反向(0);c1=2;如果(d9= = 1)1=反向(1);2= c0;如果(d2= = 1)2=反向(2);3= c1;如果(d7= = 1)3=反向(3);打破;案例7:/ / 2 3 0 1一個(gè)0= c2;如果(d8= = 1)0=反向(0);c1=3;如果(d13= = 1)1=反向(1);2= c0;如果(d2
15、= = 1)2=反向(2);3= c1;如果(d7= = 1)3=反向(3);打破;案例8:/ / 21,3 0一個(gè)0= c3;如果(d12= = 1)0=反向(0);1= c1;如果(d5= = 1)1=反向(1);2= c0;如果(d2= = 1)2=反向(2);3= c2;如果(d11= = 1)3=反向(3);打破;案例9:/ / 2 1 0 3一個(gè)0= c2;如果(d8= = 1)0=反向(0);1= c1;如果(d5= = 1)1=反向(1);2= c0;如果(d2= = 1)2=反向(2);3= c3;如果(d15= = 1)3=反向(3);打破;案例10:/ / 2 0 3 1
16、一個(gè)0= c1;如果(d4= = 1)0=反向(0);c1=3;如果(d13= = 1)1=反向(1);2= c0;如果(d2= = 1)2=反向(2);3= c2;如果(d11= = 1)3=反向(3);打破;情形11:/ / 2 0 1 3一個(gè)0= c1;如果(d4= = 1)0=反向(0);c1=2;如果(d9= = 1)1=反向(1);2= c0;如果(d2= = 1)2=反向(2);3= c3;如果(d15= = 1)3=反向(3);打破;情形12:/ / 1 3 2 0一個(gè)0= c3;如果(d12= = 1)0=反向(0);c1=0;如果(d1= = 1)1=反向(1);2= c2
17、;如果(d10= = 1)2=反向(2);3= c1;如果(d7= = 1)3=反向(3);打破;案例13:/ / 1 3 0 2一個(gè)0= c2;如果(d8= = 1)0=反向(0);c1=0;如果(d1= = 1)1=反向(1);2= c3;如果(d14= = 1)2=反向(2);3= c1;如果(d7= = 1)3=反向(3);打破;案例14:/ / 1 2 3 0一個(gè)0= c3;如果(d12= = 1)0=反向(0);c1=0;如果(d1= = 1)1=反向(1);2= c1;如果(d6= = 1)2=反向(2);3= c2;如果(d11= = 1)3=反向(3);打破;案例15:/ /
18、 1 2 0 3一個(gè)0= c2;如果(d12= = 1)0=反向(0);c1=0;如果(d9= = 1)1=反向(1);2= c1;如果(d6= = 1)2=反向(2);3= c3;如果(d3= = 1)3=反向(3);打破;案例16:/ / 1 0 3 2一個(gè)0= c1;如果(d4= = 1)0=反向(0);c1=0;如果(d1= = 1)1=反向(1);2= c3;如果(d14= = 1)2=反向(2);3= c2;如果(d11= = 1)3=反向(3);打破;案例17:/ / 1 0 2 3一個(gè)0= c1;如果(d4= = 1)0=反向(0);c1=0;如果(d1= = 1)1=反向(1
19、);2= c2;如果(d10= = 1)2=反向(2);3= c3;如果(d15= = 1)3=反向(3);打破;案例18:/ / 0 3 2 1一個(gè)0= c0;如果(d0= = 1)0=反向(0);c1=3;如果(d13= = 1)1=反向(1);2= c2;如果(d10= = 1)2=反向(2);3= c1;如果(d7= = 1)3=反向(3);打破;案例19:/ / 0 3 1 2一個(gè)0= c0;如果(d0= = 1)0=反向(0);c1=2;如果(d9= = 1)1=反向(1);2= c3;如果(d14= = 1)2=反向(2);3= c1;如果(d7= = 1)3=反向(3);打破;
20、情形20:/ / 0 2 3 1一個(gè)0= c0;如果(d0= = 1)0=反向(0);c1=3;如果(d13= = 1)1=反向(1);2= c1;如果(d6= = 1)2=反向(2);3= c2;如果(d11= = 1)3=反向(3);打破;案例21:/ / 0 2 1 3一個(gè)0= c0;如果(d0= = 1)0=反向(0);c1=2;如果(d9= = 1)1=反向(1);2= c1;如果(d6= = 1)2=反向(2);3= c3;如果(d15= = 1)3=反向(3);打破;案例22:/ / 0 1 3 2一個(gè)0= c0;如果(d0= = 1)0=反向(0);1= c1;如果(d5= =
21、 1)1=反向(1);2= c3;如果(d14= = 1)2=反向(2);3= c2;如果(d11= = 1)3=反向(3);打破;案例23:/ / 0 1 2 3一個(gè)0= c0;如果(d0= = 1)0=反向(0);1= c1;如果(d5= = 1)1=反向(1);2= c2;如果(d10= = 1)2=反向(2);3= c3;如果(d15= = 1)3=反向(3);打破;默認(rèn)值:打破;/ /解密函數(shù)中使用的排列碼表空白decode()開(kāi)關(guān)(剩余部分)例0:/ / 3 2 1 0如果(d12= = 1)0=反向(0);f3=0;如果(d9= = 1)1=反向(1);f2=1;如果(d6= =
22、 1)2=反向(2);f1=2;如果(d3= = 1)3=反向(3);f0=3;打破;案例1:/ / 3 2 0 1如果(d8= = 1)0=反向(0);f2=0;如果(d13= = 1)1=反向(1);f3=1;如果(d6= = 1)2=反向(2);f1=2;如果(d3= = 1)3=反向(3);f0=3;打破;情形2:/ / 3 1 2 0如果(d12= = 1)0=反向(0);f3=0;如果(d5= = 1)1=反向(1);f1=1;如果(d10= = 1)2=反向(2);f2=2;如果(d3= = 1)3=反向(3);f0=3;打破;案例3:/ / 3 1 0 2如果(d8= = 1)
23、0=反向(0);f2=0;如果(d5= = 1)1=反向(1);f1=1;如果(d14= = 1)2=反向(2);f3=2;如果(d3= = 1)3=反向(3);f0=3;打破;案例4:/ / 3 0 2 1如果(d4= = 1)0=反向(0);f1=0;如果(d13= = 1)1=反向(1);f3=1;如果(d10= = 1)2=反向(2);f2=2;如果(d3= = 1)3=反向(3);f0=3;打破;案例5:/ / 3 0 1 2如果(d4= = 1)0=反向(0);f1=0;如果(d9= = 1)1=反向(1);f2=1;如果(d14= = 1)2=反向(2);f3=2;如果(d3=
24、= 1)3=反向(3);f0=3;打破;案例6:/ / 2 3 1 0如果(d12= = 1)0=反向(0);f3=0;如果(d9= = 1)1=反向(1);f2=1;如果(d2= = 1)2=反向(2);f0=2;如果(d7= = 1)3=反向(3);f1=3;打破;案例7:/ / 2 3 0 1如果(d8= = 1)0=反向(0);f2=0;如果(d13= = 1)1=反向(1);f3=1;如果(d2= = 1)2=反向(2);f0=2;如果(d7= = 1)3=反向(3);f1=3;打破;案例8:/ / 21,3 0如果(d12= = 1)0=反向(0);f3=0;如果(d5= = 1)
25、1=反向(1);f1=1;如果(d2= = 1)2=反向(2);f0=2;如果(d11= = 1)3=反向(3);f2=3;打破;案例9:/ / 2 1 0 3如果(d8= = 1)0=反向(0);f2=0;如果(d5= = 1)1=反向(1);f1=1;如果(d2= = 1)2=反向(2);f0=2;如果(d15= = 1)3=反向(3);f3=3;打破;案例10:/ / 2 0 3 1如果(d4= = 1)0=反向(0);f1=0;如果(d13= = 1)1=反向(1);f3=1;如果(d2= = 1)2=反向(2);f0=2;如果(d11= = 1)3=反向(3);f2=3;打破;情形1
26、1:/ / 2 0 1 3如果(d4= = 1)0=反向(0);f1=0;如果(d9= = 1)1=反向(1);f2=1;如果(d2= = 1)2=反向(2);f0=2;如果(d15= = 1)3=反向(3);f3=3;打破;情形12:/ / 1 3 2 0如果(d12= = 1)0=反向(0);f3=0;如果(d1= = 1)1=反向(1);f0=1;如果(d10= = 1)2=反向(2);f2=2;如果(d7= = 1)3=反向(3);f1=3;打破;案例13:/ / 1 3 0 2如果(d8= = 1)0=反向(0);f2=0;如果(d1= = 1)1=反向(1);f0=1;如果(d14
27、= = 1)2=反向(2);f3=2;如果(d7= = 1)3=反向(3);f1=3;打破;案例14:/ / 1 2 3 0如果(d12= = 1)0=反向(0);f3=0;如果(d1= = 1)1=反向(1);f0=1;如果(d6= = 1)2=反向(2);f1=2;如果(d11= = 1)3=反向(3);f2=3;打破;案例15:/ / 1 2 0 3如果(d12= = 1)0=反向(0);f2=0;如果(d9= = 1)1=反向(1);f0=1;如果(d6= = 1)2=反向(2);f1=2;如果(d3= = 1)3=反向(3);f3=3;打破;案例16:/ / 1 0 3 2如果(d4= = 1)0=反向(0);f1=0
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 生態(tài)養(yǎng)殖基地承包合同
- 項(xiàng)目進(jìn)度追蹤與協(xié)同策劃方案
- 現(xiàn)代學(xué)徒制師徒協(xié)議
- 柑橘樹(shù)承包合同
- 食品安全檢測(cè)技術(shù)研究開(kāi)發(fā)合作協(xié)議
- 汽車(chē)租賃合同租賃車(chē)輛交接確認(rèn)書(shū)
- 投資借款合同書(shū)
- 共建聯(lián)合實(shí)驗(yàn)室合作合同協(xié)議書(shū)范本模板5篇
- 活動(dòng)一《自己種菜樂(lè)趣多》(教學(xué)設(shè)計(jì))-2023-2024學(xué)年四年級(jí)上冊(cè)綜合實(shí)踐活動(dòng)滬科黔科版
- Unit4 I have a ball(教學(xué)設(shè)計(jì))-2024-2025學(xué)年人教精通版英語(yǔ)三年級(jí)上冊(cè)
- 大數(shù)據(jù)專(zhuān)業(yè)實(shí)習(xí)報(bào)告范文共5篇
- 出口退稅培訓(xùn)課件外貿(mào)企業(yè)出口退稅
- 蛋白表達(dá)及純化課件
- 304不銹鋼管材質(zhì)證明書(shū)
- DBJ 46-027-2013 海南省建筑塔式起重機(jī)安裝使用安全評(píng)定規(guī)程
- 港口集裝箱物流系統(tǒng)建模與仿真技術(shù)研究-教學(xué)平臺(tái)課件
- 杭州灣跨海大橋項(xiàng)目案例ppt課件
- (完整版)光榮榜25張模板
- 工業(yè)催化劑作用原理—金屬氧化物催化劑
- 優(yōu)秀教材推薦意見(jiàn)(真實(shí)的專(zhuān)家意見(jiàn))
- QTD01鋼質(zhì)焊接氣瓶檢驗(yàn)工藝指導(dǎo)書(shū)
評(píng)論
0/150
提交評(píng)論