【正文】
先,找到明文的 ASCII 碼值: 11 9 1 103,再給其減去 32(由于 ASCII 碼表中前 33個(gè)為不可顯示字符,因此在加密運(yùn)算過(guò)程中明文字母 pij要先減 32( ASCII 碼表中從 0 開(kāi)始)),求完模之后的結(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]。 測(cè)試數(shù)據(jù): tangyang 密鑰 m: 2 n: 7 根據(jù)給定測(cè)試數(shù)據(jù)得加密后的數(shù)據(jù)為: pJdVzJdV,如圖 所示: 圖 仿射加密法加密測(cè)試 將測(cè)試數(shù)據(jù)加密后的數(shù)據(jù)解密后得原測(cè)試數(shù)據(jù): tangyang.,如圖 所示: 圖 仿射加密法解密測(cè)試 多文字加密算法測(cè)試 多文字加密法的密鑰為 5 5 的矩陣,關(guān)鍵字用 5 個(gè)不重復(fù)的字母來(lái)標(biāo)志。 此軟件也存在一些弊端,比如,如果能將所有加密算法 進(jìn)行 動(dòng)態(tài)演示 將 會(huì)得到更好的教學(xué)效果 。 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. 陜西理工學(xué)院畢業(yè)設(shè)計(jì) 第 25 頁(yè) 共 45 頁(yè) 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)。 陜西理工學(xué)院畢業(yè)設(shè)計(jì) 第 23 頁(yè) 共 45 頁(yè) 參考文獻(xiàn) [1] Richard Spillman. 經(jīng)典密碼學(xué)與現(xiàn)代密碼學(xué) [M]. 葉阮健 ,曹英 ,張長(zhǎng)富譯 . 北京 :清華大學(xué)出版社 ,. [2] 邵珠艷 ,岳麗 . 線(xiàn)性代數(shù) [M].北京市 :北京大學(xué)出版社 , . [3] 譚浩強(qiáng) . C程序設(shè)計(jì)(第三版) [M]. 北京 :清華大學(xué)出版社 , 20xx. [4] Stanley Josee Lagole Barbara E. Moo 著 . C++ Primer 中文版 [M].李師賢 ,蔣愛(ài)軍 ,梅曉勇 ,林瑛譯 . 人民郵電出版社 . [5] 錢(qián)能 . C++程序設(shè)計(jì)教程 [M]. 北京 :清華大學(xué)出版社 , . 陜西理工學(xué)院畢業(yè)設(shè)計(jì) 第 24 頁(yè) 共 45 頁(yè) 科技外文文獻(xiàn) 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。 在分析研究的基礎(chǔ)上做了一定的改進(jìn),其改進(jìn)主要體現(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。其破解過(guò)程跟仿射加密法的破解過(guò)程類(lèi)似,即用已知明文 — 密文組建方程組,求解該方程組后,就可以找到其密鑰矩陣。再將這些數(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)。 陜西理工學(xué)院畢業(yè)設(shè)計(jì) 第 9 頁(yè) 共 45 頁(yè) int flag = 0。 (())。 解密過(guò)程:要破譯 Vigenere 加密法,需要顛倒該查找過(guò)程。 return result。 k++。 for(i = 0。 int flag。 n++。) mid = 39。 while(k textLen) { flag = 0。 CString result。這個(gè)矩陣的 5 行和 5 列用含有 5 個(gè)字母的關(guān)鍵詞來(lái)標(biāo)識(shí),該關(guān)鍵詞不能有重復(fù)的字母。 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 算法分析 仿射加密法與單碼加密替換沒(méi)有什么不同,因?yàn)槊魑牡拿總€(gè)字母分別只映射到一個(gè)密文字母。事實(shí)上,選擇一種合適的加密機(jī)制將能消除消費(fèi)者的各種 信息 安全隱患。該軟件基于 Microsoft Visual C++ 集成開(kāi)發(fā)環(huán)境,采用 C++面向?qū)ο蟪绦蛟O(shè)計(jì)方法,根據(jù)經(jīng)典密碼學(xué)中的單碼加密、多碼加密以及多圖加密算 法,實(shí)現(xiàn)了經(jīng)典密碼學(xué)中的仿射加密法、多文字加密法、 Vigenere 加密法和 Hill 加密法四種經(jīng)典加密算法的教學(xué)演示效果。 六、畢業(yè)設(shè)計(jì)的進(jìn)度安排: 至 20xx320 搜集文獻(xiàn)材料,撰寫(xiě)開(kāi)題報(bào)告 20xx320 至 20xx331 進(jìn)行設(shè)計(jì)分析,確定設(shè)計(jì)方案 20xx401 至 20xx415 概要 設(shè)計(jì),構(gòu)思設(shè)計(jì)平臺(tái)的整體框架 20xx416 至 20xx515 詳細(xì)設(shè)計(jì)、搭建平臺(tái),編寫(xiě)代碼 20xx515 至 20xx525 軟件測(cè)試、系統(tǒng)完善 20xx526 至 20xx605 撰寫(xiě)畢業(yè)設(shè)計(jì)說(shuō)明書(shū) 20xx606 至 20xx610 整理資料、準(zhǔn)備答辯及答辯 20xx611 至 20xx620 資料完善工作 指導(dǎo)教師簽名 專(zhuān)業(yè)負(fù)責(zé)人簽名 學(xué)院領(lǐng)導(dǎo)簽 名 批準(zhǔn)日期 陜西理工學(xué)院畢業(yè)設(shè)計(jì) 一款經(jīng)典加密解密教學(xué)演示軟件的開(kāi)發(fā) 湯陽(yáng) (陜西理工學(xué)院數(shù)學(xué)與計(jì)算機(jī)科學(xué)學(xué)院計(jì)算機(jī)科學(xué)與技術(shù)計(jì)專(zhuān)升本 1301 班 ,陜西 漢中 723000) 指導(dǎo)教師:李 軍 【摘要】 為了在密碼學(xué)教學(xué)過(guò)程中形象的展示加密解密這一過(guò)程,設(shè)計(jì)實(shí)現(xiàn)了一款經(jīng)典加密解密教學(xué)演示軟件。 天貓 商城、支付寶和當(dāng)當(dāng)網(wǎng)也已被卷入其中。現(xiàn)在,假設(shè)p 為明文字母的數(shù)字(譯注:即該字母在字母表中對(duì)應(yīng)的數(shù)字), c 為密文字母的數(shù)字, m1為 m 的乘法的逆元, n1為 n 的加法的逆元,那么,這兩個(gè)數(shù)字之間的關(guān)系可以用如下等式表示: 26 m od )( nmpc ?? 26 m o d )( 11 ?? ?? ncmp 由于傳統(tǒng)的仿射加密算法只對(duì) 26 個(gè)字母進(jìn)行加密,為了解決這一局限,對(duì)一般符號(hào)也能進(jìn)行加密,從而采用 ASCII 碼表作為加密參考,將模改為 95(注: ASCII 碼值有 128 個(gè),由于前 33 個(gè)為不可顯示字符,因此在加密的過(guò)程中排除,故將模改為 95)。 N = ()。 Passwd[i] = c + 32。i++) { n = 95 * i + 1。 obvious = new char[N]。 p = (fa * m_b) % 95。 多文字加密法的密鑰是一個(gè) 5 5 的矩陣。 核心代碼 //加密函數(shù) CString CMoreWordPasswd::MWAddPass(CStrin