希尔密码
Now, Hill Cipher
Hill Cipher是一种非常基本的加密技术,用于将字符串转换为密文。 这项技术是由美国数学家“莱斯特·桑德斯·希尔(Lester Sanders Hill)”发明的。 这是一个多图形替换密码,因为替换或加密是在字母上的块上执行的。 它可以同时处理多个字母。 这是第一个可用于3个以上符号的多重密码。
Implementation Technique
实施技术
(Encryption )
In Hill Cipher, each letter is represented by a number modulo 26. So according to this, A = 0, B = 1, C = 2, ..., Z = 25. A string will be given to you and you have to make a column matrix using the letter-numberer relationship shown above. We'll be given a key matrix as well. We must ensure that | Key | should not be zero otherwise we can not apply hill cipher technique. This key matrix will be used in decryption as well. We need to multiply these two matrices. The formula for the ciphertext using Hill Cipher
Hill Cipher中 ,每个字母都由一个以26为模的数字表示。因此, A = 0,B = 1,C = 2,...,Z = 25 。 将为您提供一个字符串,您必须使用上面显示的字母-数字关系创建一个列矩阵。 我们还将获得一个密钥矩阵。 我们必须确保 关键 不应为零,否则我们将无法应用希尔密码技术 。 该密钥矩阵也将用于解密。 我们需要将这两个矩阵相乘。 使用希尔密码的密文公式为:
Here, n is the order of matrix or we can say the n is the number of letters we are taking at once to encrypt. Now, you'll get column matrix of order n x 1
n是矩阵的阶数,或者我们可以说n是我们一次要加密的字母数。 现在,您将获得顺序为nx 1的列矩阵,该列矩阵的数字从0到25。您只需要用上面显示的关系中的字母替换数字,即可准备好密文。
(Decryption)
The letter-numberer relationship will remain the same in the decryption part. We'll use the inverse of the key matrix in decryption. Order of the matrix will remain the same. We need to multiply the inverse of the key matrix with the cipher text matrix we've got from the encryption technique. The formula is given below:
字母-数字关系在解密部分将保持不变。 我们将在解密中使用密钥矩阵的逆函数。 矩阵的顺序将保持不变。 我们需要将密钥矩阵的逆乘以从加密技术获得的密文矩阵。 公式如下:
Example:
例:
Let us take plain text: DOG and the key matrix is:
让我们采用纯文本:DOG和密钥矩阵为:
D = 3, O = 14 , G = 6 so our column matrix is:
D = 3,O = 14,G = 6,所以我们的列矩阵为:
Now we have to apply the multiplication as shown in the encryption formula. After multiplying and applying modulo 26 we got this cipher text matrix:
现在,我们必须应用加密公式中所示的乘法。 在乘并应用模26之后,我们得到了这个密文矩阵:
Now, 22 = W, 11 = L, 24 = Y
现在,22 = W,11 = L,24 = Y
So cipher text of DOG is WLY
所以DOG的密文是WLY
Now we'll do decryption and we'll use the generated ciphertext to convert it to plain text. First of all, we need to find the inverse of the key matrix. So the inverse of our key matrix is:
现在我们将进行解密,并将使用生成的密文将其转换为纯文本。 首先,我们需要找到密钥矩阵的逆矩阵。 因此,我们的密钥矩阵的逆是:
Now after multiplying the inverse matrix with the ciphertext matrix that we've generated in the encryption, we can get out plain text matrix again.
现在,将逆矩阵与我们在加密中生成的密文矩阵相乘后,我们可以再次得到纯文本矩阵。
So after multiplying and taking modulo 26, the decrypted matrix is:
因此,在乘以26后,解密后的矩阵为:
3 = D, 14 = 0 and 6 = G, So this is equal to the plain text it means our encryption and decryption both are right. Now, the Hill Cipher technique
希尔密码技术已经结束。
翻译自: https://www.includehelp.com/cyber-security/hill-cipher.aspx
希尔密码