My-/FourSquareCypher

'Q' and 'J' bug

Opened this issue · 3 comments

My- commented

Then encrypting text and in the text, letters 'Q' or 'J' is "meet" before 'K' and 'I' then in the decrypted text all 'K' and 'Q' are replaced to 'Q'. The same story with 'I' and 'J', they are replaced to 'J'.
But here are n problem then 'K' and 'I' appears earlier than 'Q' and 'J'.

My- commented

That's because in default mode 'Q' is replaced with 'K' and 'J' with 'I'. So getIndex(letter) returns same position for original and replacement letter. And then dynamically creating a bigrams lookup table first appeared letter is inserted in bigrams lookup table. And that bigram is never changed afterwards.

My- commented

Fix: Is to populate bigram lookup table with 'K' and 'I' containing bigrams before dynamically populating them. That could be done by calling encrypt method with all possible bigrams containing 'K' and 'I'.

My- commented

prepopulate(letter) method id doing that.