8000 Update Playfair explanation (#191) · StenTech/Algorithms-Explanation@c8508db · GitHub
[go: up one dir, main page]

Skip to content

Commit c8508db

Browse files
soxfox42Panquesito7vbrazo
authored
Update Playfair explanation (TheAlgorithms#191)
* Fix Playfair example matrices * Change Playfair filler letter to X This matches the Python implementation, the video linked on the page, and most documentation of the Playfair cipher. * Clarify duplicate pairs in Playfair I think this wording is a little clearer when it comes to how double letter digraphs should be handled. Co-authored-by: David Leal <halfpacho@gmail.com> Co-authored-by: Vitor Oliveira <vbrazo@gmail.com>
1 parent 3706520 commit c8508db

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

en/Ciphers/playfair-cipher.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ The rules above are used for Encryption. Can be applied vice-versa for Decryptio
5353
```
5454
[m o n a r]
5555
[c h y b d]
56-
[e f g k i]
56+
[e f g i k]
5757
[l p q s t]
5858
[u v w x z]
5959
```
6060

61-
2. Split the plaintext in digraphs(pair of two). If there is an odd number of letters, a Z is added to the last letter. Pair cannot be made with same letter. Break the letter in single and add a bogus letter to the previous letter.
61+
2. Split the plaintext in digraphs(pair of two). If there is an odd number of letters, an X is added to the last letter. Pairs cannot be made with same letter. If this occurs, split the pair by adding an X between the duplicate letters.
6262

6363
```
64-
'in' 'st' 'ru' 'me' 'nt' 'sz'
64+
'in' 'st' 'ru' 'me' 'nt' 'sx'
6565
```
6666

6767
3. Now, we need to follow the rules for encrypting and do as follows:
6868

6969
```
70-
Plain Text: instrumentsz
70+
Plain Text: instrumentsx
7171
key: monarchy
7272
Encryption:
7373
i -> g
@@ -80,10 +80,10 @@ The rules above are used for Encryption. Can be applied vice-versa for Decryptio
8080
e -> l
8181
n -> r
8282
t -> q
83-
s -> t
84-
z -> x
83+
s -> x
84+
x -> a
8585
```
86-
So we will get the encrypted text as **gatlmzclrqtx**.
86+
So we will get the encrypted text as **gatlmzclrqxa**.
8787

8888
### Decryption
8989

@@ -92,17 +92,17 @@ So we will get the encrypted text as **gatlmzclrqtx**.
9292
```
9393
[m o n a r]
9494
[c h y b d]
95-
[e f g k i]
95+
[e f g i k]
9696
[l p q s t]
9797
[u v w x z]
9898
```
9999

100100
2. We need to split the ciphertext as done for plaintext while encrypting
101101
```
102-
'ga' 'tl' 'mz' 'cl' 'rq' 'tx'
102+
'ga' 'tl' 'mz' 'cl' 'rq' 'xa'
103103
```
104104

105-
3. For the previous Cipher Text **gatlmzclrqtx**, by following the rules we get:
105+
3. For the previous Cipher Text **gatlmzclrqxa**, by following the rules we get:
106106

107107
```
108108
Plain Text: gatlmzclrqtx
@@ -113,9 +113,9 @@ So we will get the encrypted text as **gatlmzclrqtx**.
113113
mz -> ru
114114
cl -> me
115115
rq -> nt
116-
tx -> sz
116+
xa -> sx
117117
```
118-
So we will get the encrypted text as **instrumentsz**.
118+
So we will get the encrypted text as **instrumentsx**.
119119

120120
## Implementations
121121

0 commit comments

Comments
 (0)
0