【正文】
先,找到明文的 ASCII 碼值: 11 9 1 103,再給其減去 32(由于 ASCII 碼表中前 33個為不可顯示字符,因此在加密運算過程中明文字母 pij要先減 32( ASCII 碼表中從 0 開始)),求完模之后的結(jié)果再加上 32。 (textLen)。 } if (less == 1) { Passwd[j] = obvious[j]。 CString result。 (textLen)。 } if (less == 1) { obvious[j] = Passwd[j]。 CString result。 j++) { ArrayKey[i][j] = array[i][j]。 測試數(shù)據(jù): tangyang 密鑰 m: 2 n: 7 根據(jù)給定測試數(shù)據(jù)得加密后的數(shù)據(jù)為: pJdVzJdV,如圖 所示: 圖 仿射加密法加密測試 將測試數(shù)據(jù)加密后的數(shù)據(jù)解密后得原測試數(shù)據(jù): tangyang.,如圖 所示: 圖 仿射加密法解密測試 多文字加密算法測試 多文字加密法的密鑰為 5 5 的矩陣,關(guān)鍵字用 5 個不重復的字母來標志。 此軟件也存在一些弊端,比如,如果能將所有加密算法 進行 動態(tài)演示 將 會得到更好的教學效果 。 public: int f(int x)。 end implementation Foo (int) f:(int)x {...} (float) g:(int)x :(int)y {...} end In C++, attributes and methods are declared together inside the braces of the class. 陜西理工學院畢業(yè)設計 第 25 頁 共 45 頁 Methodimplementation syntax is similar to C, with the addition of the scope resolution operator (Foo :: ). In ObjectiveC, attributes and methods cannot be mixed. The attributes are declared in braces,the methods follow. Their implementation lies in an implementation block. This is a major difference with C++, since some methods can be implemented without beingexposed in the interface. This is detailed later. Briefly, this is a way to clean up header files byremoving unnecessary declarations (“private” methods, and silently redefined virtual methods likedestructors). Please see Section on page 21 for further explanations. Instance methods are prefixed by the minus symbol “”, and class methods by the plus symbol“+”(cf. section on page 18)。 陜西理工學院畢業(yè)設計 第 23 頁 共 45 頁 參考文獻 [1] Richard Spillman. 經(jīng)典密碼學與現(xiàn)代密碼學 [M]. 葉阮健 ,曹英 ,張長富譯 . 北京 :清華大學出版社 ,. [2] 邵珠艷 ,岳麗 . 線性代數(shù) [M].北京市 :北京大學出版社 , . [3] 譚浩強 . C程序設計(第三版) [M]. 北京 :清華大學出版社 , 20xx. [4] Stanley Josee Lagole Barbara E. Moo 著 . C++ Primer 中文版 [M].李師賢 ,蔣愛軍 ,梅曉勇 ,林瑛譯 . 人民郵電出版社 . [5] 錢能 . C++程序設計教程 [M]. 北京 :清華大學出版社 , . 陜西理工學院畢業(yè)設計 第 24 頁 共 45 頁 科技外文文獻 3 Classes and objects ObjectiveC is an objectoriented language: it manages classes and objects. ObjectiveC uses astrict ob ject mo del, unlike C++ which has many discrepancies against the ideal object model. Forinstance, in ObjectiveC, classes are objects and can be dynamically managed: it is possible to addclasses at runtime, create instances based on the name of the class, ask a class for its methods,and so on. This is much more powerful than C++ RTTI (cf. section on page 62), which havebeen added to a very “static” language. Discouraging RTTI use is mon since the results maydepend on the piler itself and lack portability. Root class, type id, nil and Nil values In an objectoriented language, each program makes use of a set of classes. Unlike C++, ObjectiveCdefines a root class. Every new class should be a descendant of the root class. In Cocoa, that classis NSObject, and it provides a huge number of facilities for the runtime system. The root classnotion is not specific to ObjectiveC。 在分析研究的基礎上做了一定的改進,其改進主要體現(xiàn)為: 仿射加密算法及 Hill 加密算法中將模 26 改為模 95。 j++) { ArrayNKey[i][j] = array[i][j]。 i++) { for (j = 0。 } obvious[textLen] = 39。 j = j + 4。 int less = textLen % 4。 } Passwd[textLen] = 39。 j = j + 4。 int less = textLen % 4。其破解過程跟仿射加密法的破解過程類似,即用已知明文 — 密文組建方程組,求解該方程組后,就可以找到其密鑰矩陣。再將這些數(shù)值轉(zhuǎn)換回字母后,就得到其密文。\039。 for (t = 0。 chPassKey[k] 91) { chi = chPassKey[k] + 32。 obvious = new char[textLen]。 i++) { if (ArrayNum[i] == ch) return i。 flag = 0。amp。 getPassKey(passKey,chPassKey,textLen)。 陜西理工學院畢業(yè)設計 第 9 頁 共 45 頁 int flag = 0。 (())。 解密過程:要破譯 Vigenere 加密法,需要顛倒該查找過程。 return result。 k++。 for(i = 0。 int flag。 n++。) mid = 39。 while(k textLen) { flag = 0。 CString result。這個矩陣的 5 行和 5 列用含有 5 個字母的關(guān)鍵詞來標識,該關(guān)鍵詞不能有重復的字母。 obvious[i] = p + 32。 char *m_a = (())。 if ((n % a) == 0) return n/a。 } Passwd[i] = 39。 Passwd = new char[N]。因此,明文字母的數(shù)字 p 與密文字母的數(shù)字 c 之間的關(guān)系可表示為: 95 m od )( nmpc ?? 95 m o d )( 11 ?? ?? ncmp 算法分析 仿射加密法與單碼加密替換沒有什么不同,因為明文的每個字母分別只映射到一個密文字母。事實上,選擇一種合適的加密機制將能消除消費者的各種 信息 安全隱患。該軟件基于 Microsoft Visual C++ 集成開發(fā)環(huán)境,采用 C++面向?qū)ο蟪绦蛟O計方法,根據(jù)經(jīng)典密碼學中的單碼加密、多碼加密以及多圖加密算 法,實現(xiàn)了經(jīng)典密碼學中的仿射加密法、多文字加密法、 Vigenere 加密法和 Hill 加密法四種經(jīng)典加密算法的教學演示效果。 六、畢業(yè)設計的進度安排: 至 20xx320 搜集文獻材料,撰寫開題報告 20xx320 至 20xx331 進行設計分析,確定設計方案 20xx401 至 20xx415 概要 設計,構(gòu)思設計平臺的整體框架 20xx416 至 20xx515 詳細設計、搭建平臺,編寫代碼 20xx515 至 20xx525 軟件測試、系統(tǒng)完善 20xx526 至 20xx605 撰寫畢業(yè)設計說明書 20xx606 至 20xx610 整理資料、準備答辯及答辯 20xx611 至 20xx620 資料完善工作 指導教師簽名 專業(yè)負責人簽名 學院領(lǐng)導簽 名 批準日期 陜西理工學院畢業(yè)設計 一款經(jīng)典加密解密教學演示軟件的開發(fā) 湯陽 (陜西理工學院數(shù)學與計算機科學學院計算機科學與技術(shù)計專升本 1301 班 ,陜西 漢中 723000) 指導教師:李 軍 【摘要】 為了在密碼學教學過程中形象的展示加密解密這一過程,設計實現(xiàn)了一款經(jīng)典加密解密教學演示軟件。 天貓 商城、支付寶和當當網(wǎng)也已被卷入其中?,F(xiàn)在,假設p 為明文字母的數(shù)字(譯注:即該字母在字母表中對應的數(shù)字), c 為密文字母的數(shù)字, m1為 m 的乘法的逆元, n1為 n 的加法的逆元,那么,這兩個數(shù)字之間的關(guān)系可以用如下等式表示: 26 m od )( nmpc ?? 26 m o d )( 11 ?? ?? ncmp 由于傳統(tǒng)的仿射加密算法只對 26 個字母進行加密,為了解決這一局限,對一般符號也能進行加密,從而采用 ASCII 碼表作為加密參考,將模改為 95(注: ASCII 碼值有 128 個,由于前 33 個為不可顯示字符,因此在加密的過程中排除,故將模改為 95)。 N = ()。 Passwd[i] = c + 32。i++) { n = 95 * i + 1。 obvious = new char[N]。 p = (fa * m_b) % 95。 多文字加密法的密鑰是一個 5 5 的矩陣。 核心代碼 //加密函數(shù) CString CMoreWordPasswd::MWAddPass(CStrin