Question
Part 1 Please write a function/method to implement a stream cipher algorithm which takes three inputs 1- The message to encrypt (A string) 2- The
Part 1
Please write a function/method to implement a stream cipher algorithm which takes three inputs
1- The message to encrypt (A string)
2- The key (A string)
3- The algorithm (A string that is one of these: OR, AND, XOR)
Constraints
1- The key can not be bigger than the message string.
2- If the key is smaller than the message, the key should be repeated to match the size of message.
Example:
Message = 10101010011110010 Key = 1100
10101010011110010 - Message
11001100110011001 - Key with the size adjusted to the message.
3 - The function should not accept an algorithm other than OR, AND, XOR. If tried, it should give the message "Unknown algorithm"
Function
1 - Convert message and the key into binary form.
2 - Apply the given operation on the input and the key.
3 - Convert the resulted output into String
Part 2
1 - Explain the advantages and disadvantages of block and stream ciphers in a paragraph
2 - Explain the advantages and disadvantages of synchronous and asynchronous ciphers in a paragraph
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started