How to apply this python code? def encrypt_text(text, key): encrypted_text = '' # insert your code here # return encrypted_text text = input() key = input() print(encrypt_text(text, key))
How to apply this python code? def encrypt_text(text, key): encrypted_text = '' # insert your code here # return encrypted_text text = input() key = input() print(encrypt_text(text, key))
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
How to apply this python code?
def encrypt_text(text, key):
encrypted_text = ''
# insert your code here #
return encrypted_text
text = input()
key = input()
print(encrypt_text(text, key))

Transcribed Image Text: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.

Transcribed Image Text:Sample Input 0
Hello World
udd
Sample Output 0
Kbiol|Zlooa
Sample Input 1
abracadabra
uu
Sample Output 1
cdtcecfcdtc
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education