
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:PART 1
1. Using python, create a program with a function of enc_text(text, key) to encrypt the variable text using the
provided key (executing a modified version of Ceasar Cipher). Follow these rules:
а.
The key will contain a word made up of the letters 'a' and 'b'. The cipher will use the key to know the
direction of the shift:
• 'a' - the character must be shifted upwards
• 'b' - the character is to be shifted downward.
b. The number of characters in the key will determine the number of positions to shift.
c. The given text variable will only have characters from the ASCII table (values between 32 and 126).
d. If the key is invalid (contains characters other than a and b or an empty string) or the text is invalid
(empty string), no encryption will happen and the function returns the original text.
e. The key will loop through again to accommodate the additional text characters if the text has more
characters than the key.
Brute force solutions will not be accepted and an iterative approach should be used to solve this
problem.
f.
g.
The user will enter two strings one after the other:
• the first will be the text to encrypt
• the second will be the key used to encrypt it
h. 0<=len(text)<=1000 0<=len(key)<=1000 len(key) can be greater than len(text)
2. Use the guiding codes below and complete the program. Run the sample inputs below and the codes must get
the exact expected output.
3. Take a screenshot of your codes on your python complier and the expected output as well.
def enc_text(text, key):
encrypted_text
2########################
############
# place your code here #
########################
return encrypted_text
if
main_":
_name
text = input()
key = input ()
print(enc_text(text, key))
SAMPLE INPUT 1
SAMPLE INPUT 2
SAMPLE INPUT 3
Hello World
abracadabra
expelliarmus!
abb
aa
bbb
EXPECTED OUTPUT
EXPECTED OUTPUT
EXPECTED OUTPUT
cdtcecfcdtc
Kbiol|Zlooa
bumbiif^ojrp}
PART 2
1. Using python, create a program with a function of dec_text(text, key) to decrypt text applying version of Ceasar
Cipher described in PART 1.
2. Use the guiding codes below and complete the program. Run the sample inputs below and the codes must get
the exact expected output.
3. Take a screenshot of your codes on your python complier and the expected output as well.
def dec_text(encrypted_text, key):
decrypted_text
##############
#####
######
# place your code here #
####################################################
return decrypted_text
if
main_":
name
text = input ()
key = input()
print(dec_text(text, key))
==
SAMPLE INPUT 1
SAMPLE INPUT 2
SAMPLE INPUT 3
Kbiol|Zlooa
cdtcecfcdtc
bumbiif^ojrp}
abb
aa
bbb
EXPECTED OUTPUT
EXPECTED OUTPUT
EXPECTED OUTPUT
Hello World
abracadabra
expelliarmus!
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 nowThis is a popular solution!
Step by stepSolved in 6 steps with 5 images

Knowledge Booster
Similar questions
- Given two Python 3.9 dictionaries, d1 and d2, you run the command d1 == d2 and see that this returns True. Which of the following statements are true? Select all that apply. O The key and value pairs were inserted into d1 and d2 in the same order. O d1 and d2 have the same set of keys, but may have different values. O d1 and d2 have the same set of key and value pairs. O The values in d1 must have the same order that they do in d2. O None of the other statements are true.arrow_forwardAsaparrow_forwardNeed help writing this java code, it has three objectives: to process strings to compare, search, sort, and verify location of specific pattern to output result via interface Description Write a Java program to read a text file (command line input for file name), process the text file and perform the following. Print the total number of words in the file. (When using java_test.txt, I calculate the number of words, including number, as 254.) Print the total number of different words (case sensitive, meaning “We” and “we” are two different words) in the file. (When using java_test.txt, I calculate the number of different words, including number, as 168.) Print all words in ascending order (based on the ASCII code) without duplication. Write a pattern match method to find the location(s) of a specific word. This method should return all line number(s) and location(s) of the word(s) found in the file. Print all line(s) with line number(s) where the word is found by invoking the method…arrow_forward
- In Python using str(pd.Timestamp.now())[11:13] to get the current number of hours since midnight, write a function that returns a different greeting depending on the time of day. (Hint: use a time argument that defaults to str(pd.Timestamp.now())[11:13] so that you can test your function.)arrow_forwardI need the answer as soon as possiblearrow_forwardInstructions in python: Create a compression algorithm that will compress the text "nnneennwnneeeennwwnneeeessseeenneeesswsswwwsssswww" in the parchment piece into a smaller form. The algorithm must include simple instructions of no more than 1 or 2 sentences. It is recommended that you use basic ASCII characters, as the focus here is the algorithm rather than the physical space occupied by the result. Create a copy of this spreadsheet to organize your results and calculate the compression ratios. After working for about 10 minutes, you can access a clue: 2D Map. After another 10 minutes, you can view the 2D Map with Terrain. There are many correct answers to this exercise.arrow_forward
- ****NEEDS TO BE WRITTEN IN PYTHON**** Use the strategy of the decimal to binary conversion implemented in Project 4, and the bit shift left operation defined in Project 5 to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting bit strings.arrow_forwardPython Programmingarrow_forwardWrite a program in C to decrypt a cipher text using Caesar Cipher substitution method.Plain text was first encrypted with a Cipher Key within the range 1 to 26 and then encrypted then encrypted with key -1 (minus 1).Find the first key and write the key numbers and the decrypted plain text into text mode file "done.txt" using your programarrow_forward
- please code in python Implement an encryption function that tests that input 0xADE1 yields ciphertext (188, 153). You may hard-code these values for testing. Do NOT use ANY string/character manipulation or arithmetic functions to implement your solution.arrow_forward1. Write a program that reads two strings from the keyboard using a while loop A.Terminate the loop when both strings have the same content, done B.Display both strings if the contents are different C.For strings with the same contents, display if they are at the same address 2.Demonstrate a situation in which the JVM will use garbage collection 3.Given the following strings: Middlesex CollegeDemonstrate the use of the following String methodsconcat(), length(), trim(), charAt(), both substring()arrow_forwardWrite only one of them Java or C++ code using a file reading (the file is worth below) CreditCard.txt ***I want to solve as soon as possible.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY