【正文】
文輸入塊變?yōu)?64 位的密文輸出塊,他所使用的密鑰也是 64 位, DES 對 64 位的明文分組進(jìn)行操作 。 ( 1) 初始置換 其功能是把輸入的 64位數(shù)據(jù)塊按位重新組合,并把輸出分為 L0, R0兩部分,每部分各 長 32位,其置換規(guī)則如表 1所示 。 逆置換正好是初始置換的逆運(yùn)算。 表 3擴(kuò)展置換表 32, 1, 2, 3, 4 , 5 , 4 , 5 , 6 , 7 , 8 ,9 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16,17 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24,25 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32,1 表 4 P盒置換表 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 16, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13 , 30, 6, 22, 11, 4, 25 在( Ri, Ki) 算法描述圖中, S1, S2, ? , S8 為選擇函數(shù),其功能是把 6 b數(shù) 據(jù)變?yōu)?4 b 數(shù)據(jù)。 現(xiàn)設(shè)輸入為: D=D1D2D3D4D5D6 令:列 =D2D3D4D5,行 =D1D6 然后在 S1 表中查得對應(yīng)的數(shù),以 4位二進(jìn)制表示,此即為選擇函數(shù) S1 的輸出 。即:經(jīng)過密鑰置換表的變換后, Key 的位數(shù)由64位變成了 56 位,此 56位分為 C 0, D0 兩部分,各 28 位,然后分別進(jìn)行第一次循環(huán)左移,得到 C1, D1,將 C1(28 位 ), D1(28 位 )合并得到 56 位,再經(jīng)過壓縮置換,從而便得到了密鑰 K0(48 位 )。 DES 算法的解密過程是一樣的,區(qū)別僅在于第一次迭代 時(shí)用子密鑰 K15,第二次是 K14, ? ,最后一次用 K0,算法本 身并沒有任何變化。 ( 8 字節(jié)的倍數(shù) ) 功能 : 生成解密密鑰 , 把待解密文分割成 64 位的塊 , 逐塊完成 16次迭代解密 , 解密后的明文存放在 data 所指向的內(nèi)存中 。 (8字節(jié)的倍數(shù) ) 功能 : 生成解密密鑰 , 把待解密文分割成 64 位的塊 , 把第 i1 層解密后的 明文 作為第 i 層解密 密文輸入 , 根據(jù)用戶指定的解密層數(shù)進(jìn)行 n 層解密 , 最終生成的明文存放在 data 所指向 內(nèi)存中 。 (六) int DdesN(char *data, char *key, int n_key, int readlen) 參數(shù) : (長度為 readlen, 可能經(jīng)過填充 。而 56 位長的密鑰的窮舉空間為 256,這意味著如果一臺(tái)計(jì)算機(jī)的速度 是每秒檢測一百萬個(gè)密鑰,則他搜索完全部密鑰就需要將近 2 285 年的時(shí)間,可見這是難以實(shí)現(xiàn)的。對運(yùn)用 DES來達(dá)到保密作用的系統(tǒng)產(chǎn)生數(shù)據(jù)被破譯的危險(xiǎn),這正是 DES 算法在應(yīng)用上的誤區(qū)。 3 軟件設(shè)計(jì)與實(shí)現(xiàn) 本軟件設(shè)計(jì)和實(shí)現(xiàn)的功能主要有兩個(gè)方面,一是對文件的加密,二是對加密的文件的解密工作。對數(shù)據(jù)打包封裝在網(wǎng)絡(luò)上進(jìn)行密文傳 輸。 //獲得保存文件名 string outName = 。 if ( = 8) { desKey = new byte[]{(byte)keyString[0] ,(byte)keyString[1], (byte)keyString[2], (byte)keyString[3] , (byte)keyString[4] ,(byte)keyString[5], (byte)keyString[6], (byte)keyString[7]}。 FileStream fout = new FileStream(outName , , )。 //每次寫入的大小 int len。 //從輸入文件中讀取流 , 然后加密到輸入文件中 while (plete totlen) { len = (bin, 0, 100)。 ()。//獲得要解密的文件名 string outName = 。 if ( = 8) { desKey=new byte[]{(byte)keyString[0] ,(byte)keyString[1], (byte)keyString[2], (byte)keyString[3] , (byte)keyString[4] ,(byte)keyString[5], (byte)keyString[6], (byte)keyString[7]}。 FileStream fout = new FileStream(outName , , )。//代表已經(jīng)解密的流的大小 int len。//從輸入文件中讀取流,然后解密到輸出文件中 while (plete totlen) { len = (bin, 0, 100)。//關(guān)閉流 ()。 } catch (Exception error) { (操作有誤: + , 警告 , , )。在初始條件下,本軟件的加密控件為不可用的 ,圖中我們用綠色字體標(biāo)出位置。 圖 4 加密文件界面 按照上述要求,我們對一個(gè)位與該系統(tǒng)的 F: \修改要求的 .txt 的純文本文件進(jìn)行加密操作。單擊確定按鈕后,開始加密按鈕才為可用。數(shù)據(jù)加密完成該軟件也有相應(yīng)的提示入圖所示。 4 測試 1兩次密碼一致還滿足密碼長度大于 6如 password1=2021031306 并且同時(shí) password2=2021031306。 5未選取待加密文件路徑文件名 encode_address = “” 。 3密碼不正確 如原密碼為 2021031306,解密密碼錯(cuò)寫為 203031306。但 由于時(shí)間比較緊張,加上自己本身在語言編程方面的能力比 較有限,該軟件還存在著一定的問題。 參考文獻(xiàn) [1] 曹瑞寧 .C編程入門與提高 [M].上海:上??茖W(xué)普及出版社, 2021 [2] 戴芳勝 , 郭文夷 .Visual C.NET可視化程序設(shè)計(jì) [M].上海:華東理工大學(xué)出版社 , 2021 [3] Simon Robinson , Christian Nagel 李敏波譯 .C高級編程(第 3版) [M].北京:清華大學(xué)出版社, 2021 [4] 馮登國 .密碼分析學(xué) [M].北京:清華大學(xué)出版社 , 2021 [5] 楊義先等 .現(xiàn)代密碼新理論 [M].北京:科學(xué)出版社, 2021 [6] 蔡樂才,張仕斌 .應(yīng)用密碼學(xué) [M].中國電力出版社, 2021 [7] 楊波 .現(xiàn)代密碼學(xué) [M].北京:清華大學(xué)出版社, 2021 致 謝 本文是在 王 燚 (副教授) 的熱情關(guān)心和指導(dǎo)下完成的,他淵博的知識(shí)和嚴(yán)謹(jǐn)?shù)闹螌W(xué)作風(fēng)使我受益匪淺,對順利完成本課題起到了極大的作用。 關(guān)于學(xué)位論文使用權(quán)和研究成果知識(shí)產(chǎn)權(quán)的說明: 本人完全了解成都信息工程學(xué)院有關(guān)保管使用學(xué)位論文的規(guī)定,其中包括: ( 1)學(xué)校有權(quán)保管并向有關(guān)部門遞交學(xué)位論文的原件與復(fù)印件。 ( 5)學(xué)校可以公布學(xué)位論文的全部或部分內(nèi)容(保密學(xué)位論文在解密后遵守此規(guī)定)。s gone and put `Mother39。s initials are ., and I don39。s Mother. Hide the basket, quick! cried Jo, as a door slammed and steps sounded in the hall. Amy came in hastily, and looked rather abashed when she saw her sisters all waiting for her. Where have you been, and what are you hiding behind you? asked Meg, surprised to see, by her hood and cloak, that lazy Amy had been out so early. Don39。, while Beth ran to the window, and picked her finest rose to ornament the stately bottle. You see I felt ashamed of my present, after reading and talking about being good this morning, so I ran round the corner and changed it the minute I was up, and I39。d do it, said Mrs. March, smiling as if satisfied. You shall all go and help me, and when we e back we will have bread and milk for breakfast, and make it up at dinnertime. They were soon ready, and the procession set out. Fortunately it was early, and they went through back streets, so few people saw them, and no one laughed at the queer party. A poor, bare, miserable room it was, with broken windows, no fire, ragged bedclothes, a sick mother, wailing baby, and a group of pale, hungry children cuddled under one old quilt, trying to keep warm. How the big eyes stared and the blue lips smiled as the girls went in. Ach, mein Gott! It is good angels e to us! said the poor woman, crying for joy. Funny angels in hoods and mittens, said Jo, and set them to laughing. In a few minutes it really did seem as if kind spirits had been at wor k there. Hannah, who had carried wood, made a fire, and stopped up the broken panes with old hats and her own cloa k. Mrs. March gave the mother tea and gruel, and forted her with promises of help, while she dressed the little baby as tenderly as if it had been her own. T he girls meantime spread the table, set the children round the fire, and fed them like so many hungry birds, laughing, talking, and trying to understand the funny broken English. Das ist gut! Die Engel kinder! cried the poor things as they ate and warmed their purple hands at the fortable blaze. T he girls had never been called angel children before, and thought it very agreeable, especially Jo, who had been considered a `Sancho