The task is very simple; you have to work on two functions Encryptand Decrypt. T
ID: 3619320 • Letter: T
Question
The task is very simple; you have to work on two functions Encryptand Decrypt. The encrypt function will encrypt the user inputstring with the help of encryption key. The decrypt function willdecrypt the user input string with the help of encryption key. Theoutput will
Hints:
Encoding:
Read each character of user input and find itsASCII code using function charCodeAt. Add the key value into ASCIIcode of each character and covert new ASCII code to character byusing function fromCharCode. Display all characters into EncodedOutput box.
For example, you entered a character ‘X’, which hasASCII value 130. Add key value in 130, for example, 130+16=146.Then convert 146 to respective Character.
Decoding:
Read each character of user input and find itsASCII code using function charCodeAt. Subtract the key value fromASCII code of each character and covert new ASCII code to characterby using function fromCharCode. Display all characters intoOriginal String box.
Explanation / Answer
please rate - thanks this should get you started import java.util.*; public class encryptdecrypt { public static void main(String[] args) {String input, encryp,decrypt; char code,ch; int i,key,characters; Scanner in=new Scanner(System.in); System.out.print("Enter the key to use "); key=in.nextInt(); System.out.print("Enter a string of characters: "); while(in.hasNext()) {i=0; input=in.nextLine(); encryp=""; System.out.print("encrypted message: "); for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.