08:vigenère密碼
1)Vigenére密碼 (1) Vigenére Cipher)
This technique is an example of Polyalphabetic Substitution technique which uses 26 Caesar ciphers make up the mono-alphabetic substitution rules which follow a count shifting mechanism from 0 to 25. That is, for each plain-text character we have a corresponding substitution known as a key letter.
該技術是使用26個凱撒密碼彌補隨后的計數移動機構從0到25。也就是說,對于我們的相應取代已知為每個純文本字符的單字母替換規則多碼替代技術的一個例子關鍵信 。
To understand this technique we need to take a look on this Vigenére tableau.
要了解此技術,我們需要看一下Vigenére表格 。

The logic for this technique is simple, say for a key letter 't' and plain-text letter 'h', the corresponding cipher-text letter is at the intersection of row titled 't' and column titled 'h' thus for this case we get a ciphertext that would be 'A' based on above table.
這種技術的邏輯很簡單,例如對于一個關鍵字母“ t”和純文本字母“ h” ,相應的密文字母位于標題為“ t”的行與標題為“ h”的列的交點處。情況下,根據上表,我們將得到一個密文“ A” 。
It is clear that for encrypting a plain-text message we must need a key whose length is equal to the size of the plain-text message usually a repeating key is used.
顯然,為了加密純文本消息,我們需要一個長度等于純文本消息大小的密鑰,通常使用重復密鑰。
2)Playfair密碼 (2) Playfair Cipher)
Playfair cipher (aka Playfair square) is a cryptography technique used for manual encryption, it was introduced by Charles Wheatstone in 1854 but it was popularized by Lord Playfair hence his name used.
Playfair密碼(又名Playfair平方)是一種用于手動加密的加密技術,由Charles Wheatstone于1854年提出,但后來被Playfair勛爵推廣,因此使用了他的名字。
The Playfair cipher was used in world war I by the British army and in World war II it was used by Australians. It was because the Playfair cipher is quite fast to use and does not demand any special equipment.
Playfair密碼在第一次世界大戰中被英國軍隊使用,在第二次世界大戰中被澳大利亞人使用。 這是因為Playfair密碼使用起來非常快,并且不需要任何特殊設備。
Playfair technique has 2 major steps:
Playfair技術有兩個主要步驟:

Step 1: Creation and Population of matrix
步驟1:矩陣的創建和填充
This technique uses a 5 x 5 matrix which stores a keyword (or phrase) that becomes the key for encryption or decryption. This involves some set of fixed rule, those are:
該技術使用5 x 5矩陣 ,該矩陣存儲一個關鍵字(或短語),該關鍵字成為加密或解密的密鑰。 這涉及到一些固定規則,它們是:
Fill the keyword in the matrix row-wise from left to right, top to down.
從左到右,從上到下按行在矩陣中填充關鍵字。
Remove all repeated letters.
刪除所有重復的字母。
Enter the remaining spaces in the matrix with the rest of the English alphabets (A-Z) that were not a part of our keyword. In this process, combine I and J in the same cell of the table; in other words, if I and J is a part of the keyword disregard both I and J while filling the remaining slots.
在矩陣中輸入剩余的空格以及不屬于我們關鍵字的其余英文字母( AZ )。 在此過程中,將I和J合并到表的同一單元格中; 換句話說,如果I和J是關鍵字的一部分,則在填充其余插槽時,請同時忽略I和J。
Example:
例:
Let's take our keyword as 'INCLUDEHELP IS AWESOME'. Then 5 x 5 matrix will look as:
讓我們將關鍵字設為“ INCLUDEHELP IS AWESOME” 。 然后5 x 5矩陣將如下所示:
Step 2: Encryption
步驟2:加密
This process consist of the following process:
此過程包括以下過程:
The plain-text we want to encrypt need to broke down into a pair of alphabets. For example, if our message is "MY NAME IS POGO", it will become "MY NA ME IS PO GO".
我們要加密的純文本需要分解為一對字母。 例如,如果我們的消息是“ MY NAME IS POGO” ,它將變成“ MY NA ME IS PO GO” 。
If both alphabets are the same (or only left), add an X after the first alphabet in a pair. Encrypt the new pair (after adding X) then continue.
如果兩個字母相同(或僅向左),則在成對的第一個字母之后添加X。 加密新對(添加X之后 ),然后繼續。
- If pair appears in the same row of the matrix, replace them with a letter at its right, if it's at the right end of the row then wrapping around the left side of the row.
If pair appears in the same column of the matrix, replace them with the alphabet below them. If it's on the bottom then wrapping around the top of the row.
如果對出現在矩陣的同一列中,請用其下面的字母替換它們。 如果它在底部,則環繞該行的頂部。
If the pairis not in the same row or column, replace them with the alphabets in the same row respectively, but at the other pair of cornersof the rectangle defined by the original pair. The order is quite significant here. The first encrypt alphabet of the pair is the one that is present on the same row as the first plaintext alphabet.
如果該對不在同一行或同一列中,則分別用同一行中的字母代替它們,而應替換為原始對定義的矩形的另一對角。 這里的順序非常重要。 該對中的第一個加密字母是與第一個明文字母在同一行上的字母。
Explanation:
說明:
"MY NA ME IS PO GO"
“我不喜歡我”
So we start with MY now in the above matrix it was not in the same row or column then rule 5 will apply.
因此,我們從上面的矩陣中的MY開始,因為它不在同一行或同一列中,所以將應用規則5。

Now we replace 'MY' with the diagonals that are 'KZ'.
現在我們將對角線KZ替換為MY 。
Let's move to 'NA' again they are not in the same row or column, rule 5 will apply.
讓我們再次移至“ NA”(它們不在同一行或同一列中),將應用規則5。
Now, 'NA' will be replaced with 'UE'.
現在, “ NA”將被替換為“ UE” 。
Similarly, "MY NA ME IS PO GO" will become "KZ UE FA LO DS BS".
類似地, “ MY NA ME IS PO GO”將變為“ KZ UE FA LO DS BS” 。
For the decryptionprocess, we will just follow the exact opposite steps.
對于解密過程,我們將遵循完全相反的步驟。
3)希爾密碼 (3) Hill Cipher)
The Hill cipher is based on polygraphic substitution that is it works on multiple letters at the same time, introduced by Lester Hill in 1929. This method related to the matrix theory of mathematics, specifically how to compute the inverse of a matrix.
希爾密碼是基于多重圖形替換的,它同時處理多個字母,這是萊斯特·希爾(Lester Hill)在1929年提出的。這種方法與數學的矩陣理論有關,特別是如何計算矩陣的逆。
Let's see how it works:
讓我們看看它是如何工作的:
Every Letter of plain-text will be represented by a number, so that A=0, B=1,...,Z=25.
每個純文本字母將由一個數字表示,因此A = 0,B = 1,...,Z = 25 。
We will make a matrix of the plain-text message using the above knowledge.
我們將使用以上知識來構成純文本消息的矩陣。
For example,
例如,
'CAT', so C=2, A=0, T=19. Thus our matrix lookslike:
'CAT' ,因此C = 2,A = 0,T = 19 。 因此我們的矩陣看起來像:
Now, we multiply our matrix with randomly chosen keys. The size of the key must be n x n where n is a number of rows of our plain-text matrix.
現在,我們將矩陣與隨機選擇的鍵相乘。 鍵的大小必須為nxn ,其中n是純文本矩陣的行數。
For example:
例如:
Now multiply the above matrices,
現在將上述矩陣相乘,
Now we will calculate a mod 26 value of the above matrix, that is remainder after dividing 26.
現在我們將計算上述矩陣的mod 26值,即除以26后的余數。
Translate back number to alphabets, 5=F, 8=I, 13=N. Therefore, our cipher-text is "FIN".
將數字轉換回字母,即5 = F , 8 = I , 13 = N。 因此,我們的密文為“ FIN” 。
For Decryption, take the cipher-text matrix and multiply it with the inverse of our original key matrix:
對于解密,請采用密文矩陣并將其與原始密鑰矩陣的逆矩陣相乘:
翻譯自: https://www.includehelp.com/cryptography/cryptographic-techniques-vigenére-cipher-playfair-cipher-hill-cipher.aspx
08:vigenère密碼