1. We have defined a symmetric cryptography algorithm using the XOR operator. Assume our messages (before encryption) consist of only uppercase and lowercase letters, digits and blank character. In addition, assume the key size is only one byte which is an integer between 0 and 255 (inclusive). The pseudocode of the proposed encryption algorithm is as follows: Read the message // for example message=”Hi” Read the key // for example key=10 Cipher_text=[] //an empty list for i=1 to len(message): Cipher_text= Cipher_text.append(XOR(message[i],key)) Return Cipher_text Assume XOR function, takes a character and the key, then returns the result of bitwise XOR of ASCII code of the letter with the key as an (one byte) integer. For example, if message=”Hi” and key=10, then we should first calculate the ASCCI code of “H” which is 72 and find the result of (72 XOR 10) which is 66. Then the ASCCI code of “i” is 105, so the result of (105 XOR 10) is 99. Thus the Cipher_text would be [66,99]. As another example, if message=”Hello World” and key=73 then Cipher_text=[1,44,37,37,38,105,30,38, 59,37, 45] a) Using the given algorithm, encrypt a massage as message=”firstname lastname”, replace the first name with any name and the lastname with any last name and show the message before encryption and then the encrypted message. To do so, assume the key is 53. To answer this question, you need to implement the algorithm (in any programming language). But just write down the encrypted message as the answer. b) Explain how we can decrypt the encrypted messages? Assume we have an encrypted message and the key. Write an algorithm (in pseudo code or in JS or C or C++ or Python programming languages) to describe the decryption process. c) Decrypt the following cipher text with the key=20 using your proposed algorithm in part (b). Cipher_text=[92,113,120,120,123,52,67,123,102,120,112,53]
1. We have defined a symmetric cryptography
Read the message // for example message=”Hi”
Read the key // for example key=10
Cipher_text=[] //an empty list
for i=1 to len(message):
Cipher_text= Cipher_text.append(XOR(message[i],key))
Return Cipher_text
Assume XOR function, takes a character and the key, then returns the result of bitwise XOR of ASCII code of the letter with the key as an (one byte) integer. For example, if message=”Hi” and key=10, then we should first calculate the ASCCI code of “H” which is 72 and find the result of (72 XOR 10) which is 66. Then the ASCCI code of “i” is 105, so the result of (105 XOR 10) is 99. Thus the Cipher_text would be [66,99]. As another example, if message=”Hello World” and key=73 then Cipher_text=[1,44,37,37,38,105,30,38, 59,37, 45]
a) Using the given algorithm, encrypt a massage as message=”firstname lastname”, replace the first name with any name and the lastname with any last name and show the message before encryption and then the encrypted message. To do so, assume the key is 53. To answer this question, you need to implement the algorithm (in any programming language). But just write down the encrypted message as the answer.
b) Explain how we can decrypt the encrypted messages? Assume we have an encrypted message and the key. Write an algorithm (in pseudo code or in JS or C or C++ or Python programming languages) to describe the decryption process.
c) Decrypt the following cipher text with the key=20 using your proposed algorithm in part (b). Cipher_text=[92,113,120,120,123,52,67,123,102,120,112,53]
d) One of your classmates claims that the proposed cryptography algorithm based on XOR is not secure and cipher texts can be easily decrypted even without having the key. Explain if you are agreeing or disagreeing with this classmate. Explain your reasons.
e) To improve the security of the algorithm, the encrypted message is shown as a single string. For example, if message=”Hi” and key=10, then Cipher_text=6699. As another example, if message=”Hello World” and key=73 then Cipher_text=1443737381053038593745. Explain what is the main problem with the improved version?
Step by step
Solved in 5 steps with 4 images