Performs shifting of the plaintext w.r.t. the shuffled __key_list to create the encoded_message >>> ssc = ShuffledShiftCipher('4PYIXyqeQZr44') >>> ssc.encrypt('Hello, this is a modified Caesar cipher') "d>**-1z6&'5z'5z:z+-='$'>=zp:>5:#z<'.&>#"
(self, plaintext: str)
| 147 | return decoded_message |
| 148 | |
| 149 | def encrypt(self, plaintext: str) -> str: |
| 150 | """ |
| 151 | Performs shifting of the plaintext w.r.t. the shuffled __key_list |
| 152 | to create the encoded_message |
| 153 | |
| 154 | >>> ssc = ShuffledShiftCipher('4PYIXyqeQZr44') |
| 155 | >>> ssc.encrypt('Hello, this is a modified Caesar cipher') |
| 156 | "d>**-1z6&'5z'5z:z+-='$'>=zp:>5:#z<'.&>#" |
| 157 | |
| 158 | """ |
| 159 | encoded_message = "" |
| 160 | |
| 161 | # encoding shift like Caesar cipher algorithm implementing positive shift or |
| 162 | # forward shift or right shift |
| 163 | for i in plaintext: |
| 164 | position = self.__key_list.index(i) |
| 165 | encoded_message += self.__key_list[ |
| 166 | (position + self.__shift_key) % len(self.__key_list) |
| 167 | ] |
| 168 | |
| 169 | return encoded_message |
| 170 | |
| 171 | |
| 172 | def test_end_to_end(msg: str = "Hello, this is a modified Caesar cipher") -> str: |
no outgoing calls