PYTHON3
Complete the given function, encrypt_text that encrypts the variable text using the provided key by applying a modified version of Caesar’s Cipher with the following rules:
The key will contain a word made up of the letters ‘u’ and ‘d’. The cipher will use the key to determine the direction of the shift, with a ‘u’ indicating that the character must be shifted upwards while a ‘d’ indicating a downward shift. The number of characters in the key will determine the number of positions to shift.
The given text variable will only contain characters from the ASCII table with values between 32 and 126.
If the key is invalid (empty string, contains characters other than u and d) or the text is invalid (empty string), no encryption occurs and the function returns the original text.
If the text has more characters than the key, the key will loop through again to accommodate the additional text characters.
An iterative approach should be used to solve this problem. Brute force solutions will not be accepted.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here