Simple Substitution - Searisal/Cryptography-Implementation GitHub Wiki

The simple substitution cipher, alongside its cousin the Caesar cipher, is one of few ciphers dating back to the early days of cryptography. Mathematically, it represents in injective, random mapping of the set of all letters to itself. More simply put, each letter in the plaintext is replaced by some other letter assigned to replace every instance of said plaintext letter. In order to make encryption easy, I have created a function which randomly generates a mapping for the user. Likewise, its validity can be checked with a function which makes sure that every letter maps to only one in range, and that the domain includes all possible letters. It should be noted that my version of the cipher includes not only the 26 alphabetical characters, but all visible ASCII characters which can be generated by a computer, thus giving marginally more security. Finally, in order to undo the simple substitution, one must invert the mapping. Since this is quite difficult to do in the list form read by the function, I have included a function which computes the inverse for the user.