Home /
Expert Answers /
Computer Science /
a-substitution-cipher-class-in-cryptography-a-substitution-cipher-is-one-of-the-simplest-and-mos-pa525
(Solved): A Substitution Cipher Class In cryptography, a Substitution Cipher is one of the simplest and mos ...
A Substitution Cipher Class In cryptography, a Substitution Cipher is one of the simplest and most widely known encryption techniques. Each symbol in the alphabet is replaced by another symbol in the same (or different) alphabet. For example, consider the following picture:
Assignment: Your task in this project is to implement a substitution cipher. There are two main parts to this: the Substitutioncipher class itself, and a main() driver routine which calls it. You must use a class for the substitution cipher itself. The SubstitutionCipher class Here are the specific requirements for your substitutioncipher class: 1. Implement your substitution cipher as a class, with the key as a private data member. When you create a SubstitutionCipher object you can pass in the key, which is just a string of length 26 containing all lowercase letters in the English alphabet in arbitrary order. If the key is not supplied, default to a randomly generated key. If you do pass in a key, validate that the key is legal. 2. You should have at least the following methods in your class: o _init__ ( key ): the initializer for the class o getkey () : the getter for the class key o setkey ( key ): the setter for the class key o encryptText ( text ): return the encryption (string) of the plaintext (string) argument with respect to the key o decryptText ( text ) : return the decryption of the ciphertext (string) argument with respect to the key Of course, the definitions of these will need the self parameter. See the Program Structure section below. 3. When encrypting or decrypting preserve case. That is, corresponding plaintext and ciphertext letters should have the same case (uppercase or lowercase). If the character is a nonletter, just return it unchanged. 4. You can have additional methods in the class if needed. You can also define auxiliary functions outside the class. For example, you should define the function makeRandomkey (); I've given you some code for this below. There's no reason for this to be a class method; it should be a function at the top level but can be called within the class definition.