# How to decrypt a simple substitution cipher where space is also encrypted by a character

I am trying to decrypt a text data encrypted with a simple substitution method with 2 steps. First, shift the alphabet of the source text by a few characters.

For example, if we shift by 2 characters, Hello, world! becomes Jgnnq, yqtnf!.

Secondly, Substitute space (" ") with a lower case alphabet. For example, when g and " " are to be replaced, Jgnnq, yqtnf! becomes ultimately encrypted to J nnq,gyqtnf!. Now, I am having trouble with finding which character is used to replace " ". I was thinking of using the character with the highest occurrence frequency (except e, since e has the highest frequency in the English language). But I found that it may not work always.

Does anyone has any idea how to

• Accept   (space) as also a letter? So instead of 26 you will have 27 letters. – kelalaka Jan 8 at 18:12
• @kelalaka you are correct. – Ahashan Alam Sojib Jan 8 at 18:55
• Clearly, the letter that has been swapped with space is the one that appears after commas. ;) – fkraiem Jan 8 at 20:08
• @fkraiem I also thought of this approach. but what happens when there is no comma or semi-colon in the text and the text is one line sentence? – Ahashan Alam Sojib Jan 9 at 1:43
• Other approach: try to reverse the shifting first... – fkraiem Jan 9 at 1:48