【正文】
y z a b c d e f g i i j k l m n o p q r s t u v w x y z a b c d e f g h j j k l m n o p q r s t u v w x y z a b c d e f g h i k k l m n o p q r s t u v w x y z a b c d e f g h i j l l m n o p q r s t u v w x y z a b c d e f g h i j k m m n o p q r s t u v w x y z a b c d e f g h i j k l n n o p q r s t u v w x y z a b c d e f g h i j k l m o o p q r s t u v w x y z a b c d e f g h i j k l m n p p q r s t u v w x y z a b c d e f g h i j k l m n o q q r s t u v w x y z a b c d e f g h i j k l m n o p r r s t u v w x y z a b c d e f g h i j k l m n o p q s s t u v w x y z a b c d e f g h i j k l m n o p q r t t u v w x y z a b c d e f g h i j k l m n o p q r s u u v w x y z a b c d e f g h i j k l m n o p q r s t v v w x y z a b c d e f g h i j k l m n o p q r s t u w w x y z a b c d e f g h i j k l m n o p q r s t u v x x y z a b c d e f g h i j k l m n o p q r s t u v w y y z a b c d e f g h i j k l m n o p q r s t u v w x z z a b c d e f g h i j k l m n o p q r s t u v w x y 陜西理工學(xué)院畢業(yè)設(shè)計(jì) 第 8 頁 共 45 頁 算法分析 在關(guān)鍵詞為“ make”,而明文為“ tangyang”的情況下,關(guān)聯(lián)詞 明文的關(guān)聯(lián)如下: 表 明文、密文對照表 密鑰 m a k e m a k e 明文 t a n g y a n g 加密過程:用密鑰字母確定表的行,而明文字母確定表的列,表中行列交叉處的字母就是用來替代明文字母的密文。利用密鑰和密文對,在 Vigenere中確定相應(yīng)的明文。 核心代碼 //加密函數(shù) void CVienerePasswd::getPassKey(CString text,char *result,int len) //構(gòu)建與明文字符長度相同 的密鑰數(shù)組 { int N = len / ()。 strcpy(result,strText)。 } if (M == 0) return。 char chi,chj。 Passwd = new char[textLen]。 for (k = 0。 chPassKey[k] 91) //處理大寫字母 { chi = chPassKey[k] + 32。 obvious[k] 91) { flag = 1。 j = getPassNum(chj)。 } else Passwd[k] = ArrayKey[i][j]。 return result。 } return 26。 CString result。 (textLen)。 k textLen。 } else chi = chPassKey[k]。 chj = Passwd[k] + 32。 t 26。 flag = 0。 (%s,obvious)。每個(gè)明文字母被賦予一個(gè)數(shù)值 ,通常是 a=0,b=1,? ,z=25,但 Hill 使用的是隨機(jī)賦值,塊中每個(gè)字母的數(shù)值一起用來生成一組新的數(shù)值,這些數(shù)值就用來表示密文字母。 由于傳統(tǒng)的 Hill 加密算法只對 26 個(gè)字母進(jìn)行加密,為了解決這一局限,對常用符號也能進(jìn)行加密,從而采用 ASCII 碼表作為加密參考,將模改為 95(注: ASCII 碼值有 128 個(gè),由于前 33 個(gè)為不可顯示字符,因此在加密的過程中排除,故將模改為 95)。可以用數(shù)學(xué)方法表示 Hill 加密的一般形式。 例如,選取密鑰矩陣為 4 4 可逆矩陣 , ?????????????4116109485105965968k ,明文為“ tang”。 核心代碼 //加密函數(shù) CString CHillPasswd::HillAddPass(CString newText) { int i = 0,j = 0。 obvious = (textLen)。 Passwd[j+1] = (ArrayKey[1][0] * (obvious[j] 32) + ArrayKey[1][1] * (obvious[j+1] 32) + ArrayKey[1][2] * (obvious[j+2] 32) + ArrayKey[1][3] * (obvious[j+3] 32)) % 95 + 32。 i++。 } if (less == 3) { Passwd[j] = obvious[j]。\039。 } //解密函數(shù) CString CHillPasswd::HillRelessPass(CString oldText) { int i = 0,j = 0。 Passwd = (textLen)。 obvious[j+1] = (ArrayNKey[1][0] * (Passwd[j] 32) + ArrayNKey[1][1] * (Passwd[j+1] 32) + ArrayNKey[1][2] * (Passwd[j+2] 32) + ArrayNKey[1][3] * (Passwd[j+3] 32)) % 95 + 32。 i++。 } if (less == 3) { obvious[j] = Passwd[j]。\039。 } void CHillPasswd::setArray(int array[][4]) { int i, j。 j 4。 i 4。 } } } 陜西理工學(xué)院畢業(yè)設(shè)計(jì) 第 17 頁 共 45 頁 6 系統(tǒng)測試 仿射加密算法測試 仿射加密法的密鑰是由數(shù)字對( m, n)組成,在該軟件中, m 與 95 的最大公約數(shù)為 1, n在 0~95 之間。 測試數(shù)據(jù): tangyang 陜西理工學(xué)院畢業(yè)設(shè)計(jì) 第 20 頁 共 45 頁 密鑰: 4 4 可逆矩陣 ?????????????4116109485105965968k 根據(jù)給定測試數(shù)據(jù)得加密后的數(shù)據(jù)為: =$v|eB0O,如圖 所示: 圖 Hill 加密法加密測試 將測試數(shù)據(jù)加密后的數(shù)據(jù)解密后得原測試數(shù)據(jù): tangyang,如圖 所示: 圖 Hill 加密法解密測試 經(jīng)測試,系統(tǒng)已達(dá)到設(shè)計(jì)要求。由于傳統(tǒng)仿射加密算法及 Hill 加密算法僅對 26 個(gè)英文字母進(jìn)行了加密解密,因此采用模 26 加密解密算法,為了解決這一局限,對常用符號也能進(jìn)行加密,從而采用 ASCII 碼表作為加密參考,最終采用模 95 實(shí)現(xiàn)加密算法(注: ASCII 碼值有 128 個(gè),由于前 33 個(gè)為不可顯示字符,因此在加密的過程中排除,故將模改為 95)。在此論文完成之際,謹(jǐn)向李老師致以最誠摯的感謝和敬意。 it’s related to the object model. Smalltalk and Java makeuse of a root class, while C++ does not.. Strictly speaking, every object should be of type NSObject, and every pointer to an object could be declared as NSObject*. In fact, one can use the type id instead. This is a short and handy way to declare a pointer to any object, and provides dynamic typechecking instead of static typechecking. It is very useful for some weak typing on generic methods. Please note that a null pointer to an object should be set to nil, not NULL. These values are not interchangeable. A normal C pointer can be set to NULL, but nil was introduced in ObjectiveC for pointers to objects. In ObjectiveC, classes are also objects (metaclass instances), and it is possible to declare a pointer to a class. Their null value is Nil. Class declaration It is hard to show with a single example all the differences between ObjectiveC and C++ for classdeclaration and implementation. Syntax and concepts are interleaved and require explanation. Inthe following, the differences are exposed sequentially and specifically. Attributes and methods In ObjectiveC, attributes are called instance data, and member functions are called methods. C++ ObjectiveC class Foo { double x。 int Foo::f(int x) {...} float Foo::g(int x, int y) {...} interface Foo : NSObject { double x。 this symbol has nothing to do with the UML notation andthe meaning public or private. The type of the parameters are enclosed in parenthesis, and theparameters are separated by the symbol “:”. Please see Section on the next page for furtherexplanations on the syntax of prototypes. In ObjectiveC, there is no need for a semicolon at the end of a class declaration. Also notethat the keyword to declare a class is interface and not class. The keyword class is onlyused in forward declarations (cf. section on the current page). Finally, if there is no instancedata in a class, the braces, which would enclose nothing, can be ommitted. Forward declarations: class, protocol To avoid cyclic dependencies in header files, the C language supports the forward declaration,that allows the coder to