please write in JAVA 126) thenEncryptedChar = XXXXXXXXXXOriginalChar + Key) - 127)elseEncryptedChar = (OriginalChar + Key)For example, if the enemy uses Key = 10 then the message "Hey" would...


please write in JAVA


Question 4<br>Write two methods<br>encrypt(message,key) and<br>decrypt(message,key)<br>to encrypt and decrypt messages with a key.<br>You are going to use ASCII values of each character. For example, the character 'A' is encoded using the<br>number 65 and 'B' is encoded using the number 66. Given a key, you will use the following method to<br>each letter of the message:<br>if (OriginalChar + Key > 126) then<br>EncryptedChar = 32 + ((OriginalChar + Key) - 127)<br>else<br>EncryptedChar = (OriginalChar + Key)<br>For example, if the enemy uses Key = 10 then the message
"Неy" Suppose that key =17, encrypt and decrypt the following message texts. Print encrypted and decrypted messages. msg1 = "Lost time is never found again." msg2 = "Use it or lose it." "/>
Extracted text: Question 4 Write two methods encrypt(message,key) and decrypt(message,key) to encrypt and decrypt messages with a key. You are going to use ASCII values of each character. For example, the character 'A' is encoded using the number 65 and 'B' is encoded using the number 66. Given a key, you will use the following method to each letter of the message: if (OriginalChar + Key > 126) then EncryptedChar = 32 + ((OriginalChar + Key) - 127) else EncryptedChar = (OriginalChar + Key) For example, if the enemy uses Key = 10 then the message "Hey" would initially be represented as: Character ASCII code H 72 e 101 y 121 "Hey" would be converted to "Ro$: Encrypted H = (72 + 10) = 82 = R in ASCII Encrypted e = (101 + 10) = 111 = o in ASCII Encrypted y = 32 + ((121 + 10) - 127) = 36 = $ in ASCII After conversion, the converted message will be circularly shifted left 2 characters. For example, the message “Hey" will be encrypted as "$Ro" after circular shift operation. The methods encrypt and decrypt will return the following result: encrypt("Hey", 10) → “$Ro" decrypt("SRo", 10) > "Неy" Suppose that key =17, encrypt and decrypt the following message texts. Print encrypted and decrypted messages. msg1 = "Lost time is never found again." msg2 = "Use it or lose it."
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here