Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playfair encrypt error encoding "BAAAH #13

Open
mjump-northeastern opened this issue Mar 15, 2020 · 7 comments
Open

Playfair encrypt error encoding "BAAAH #13

mjump-northeastern opened this issue Mar 15, 2020 · 7 comments

Comments

@mjump-northeastern
Copy link

We discovered that the encipher method of Playfair does not encrypt BAAAH correctly when using the key "KINGSABCDEFHLMOPQRTUVWXYZ". It returns "CBCVLW" when it should be "CBVCLW". However if I write the grid out:

KINGS
ABCDE
FHLMO
PQRTU
VWXYZ

BAAAH -> BAXAH -> BAXAHX -> CBVCLW

@omar-ashinawy
Copy link

When using two online cipher calculators, the result was: CBCVBF. The two websites are: https://www.dcode.fr/playfair-cipher and https://planetcalc.com/7751/

@eragon-saphira
Copy link

eragon-saphira commented Feb 4, 2021

This error is coming here because it is being padded with X

@omar-ashinawy
Copy link

I implemented it myself using X padding and it gave me: CBCVBF.

@eragon-saphira
Copy link

The plaintext BAAAH is padded with X. So we split as BA AA HX. Now BA are in same row so we rightshift as CB,next AA same characters so change to AX next A=(1,0) X= (4,2) so we take (1,2) and (4,0) which is CV again for HX H=(2,1) X=(4,2) so we take (2,2) and (4,1) which is LV.Correct me if I have made a mistake here and if so please tell me the correct steps

@omar-ashinawy
Copy link

I think the mistake is when you padded the end of the string first. When padding a playfair plaintext, you follow the following steps in order:

  1. Divide the string into pairs: in our case 'BAAAH' becomes: 'BA', 'AA', and 'H'. Don't worry for the single letter 'H' at the end for now.
  2. Check every pair to determine if the pair contains one repeated letter: 'BA' is OK, 'AA' has repeated A, 'H' is OK.
  3. Put 'X' between the two repeated letters in every pair: 'BAAAH' becomes: 'BA', 'AX', 'AH'
  4. Here comes the step that you did first: Check if every pair contains exactly two letters. After filling 'X', the string is already good to go so we don't need to pad the end of the string.
    Then the final plaintext: 'BA', 'AX', 'AH'.
    You can learn more from STALLINGS: CRYPTOGRAPHY AND NETWORK SECURITY PRINCIPLES AND PRACTICE
    image

@eragon-saphira
Copy link

Got it.I had misunderstood that the repeated one's second character is replaced by X.Thanks for the help and sorry for the trouble

@omar-ashinawy
Copy link

You are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants