您的位置:首页 > 娱乐 > 明星 > Cryptography and Network Security: Principles and Practice(Lesson 2 notes)

Cryptography and Network Security: Principles and Practice(Lesson 2 notes)

2024/12/27 1:22:23 来源:https://blog.csdn.net/m0_72827793/article/details/142266821  浏览:    关键词:Cryptography and Network Security: Principles and Practice(Lesson 2 notes)

Playfair Cipher

Operation steps

  1. Construct a 5×5 letter matrix based on
  2. The matrix is ​​constructed using a keyword (key)
  3. Then from left to right, from top to bottom; fill in the letters of the key in sequence (note: repeated letters in the key are not filled in), and then fill in the other letters in alphabetical order
  4. Letters I and J count as one letter

For example: take the keyword (key): monument, then the letter matrix is ​​as shown below (the matrix can only hold 25 letters, I and J are the same)
在这里插入图片描述

Encryption rules

The Playfair encryption algorithm first groups the plaintext into groups of two letters, and then finds the corresponding ciphertext in the matrix

  1. If the same letters appear in a group in the plaintext, insert a padding letter (eg: z) into the repeated plaintext letters to separate them and then regroup them (eg: balloon is regrouped intoba lz lo on)
  2. If there is only one letter when grouping into the last group, add the letter z
  3. If the plaintext letters are in the same row in the matrix, the loop will take the next letter to the right as the ciphertext (the next rightmost letter in the matrix is ​​the first leftmost letter) (eg: ar is encrypted as RM)
  4. If the plaintext letters are in the same column in the matrix, then the next letter below it is looped to be the ciphertext (the next letter at the bottom of the matrix is ​​the first one at the top) (eg: mu is encrypted as CM)
  5. If the plaintext letters are in different rows and different columns in the matrix, the letters in the same row and in the same column as another letter in the same group are the ciphertext (eg: hs is encrypted as BP, ea is encrypted as IM or JM)

Note: If the same letters appear in the keywords (keys), you need to remove the duplicate keys (skip if there are duplicates)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com