Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The primary objective of this project is to increase your understanding of the f

ID: 3885066 • Letter: T

Question

The primary objective of this project is to increase your understanding of the fundamental implementation of Veneer Cipher. You have to design and develop a C/CPP/JAVA -based program to encrypt any given message based on the Viognier algorithm. Your last name must be used as the cipher key. You also have to skip the space between the words, while replicating the key to cover the entire message. You can find an example of how the below message has been encrypted using my last name as the cipher key. A HEALTHY ATTITUDE is contagious BUT DONT WAIT TO CATCH IT OTHERS K The following messages will be given as the input as the test case to your program to check the accuracy of your program: a healthy is con but don't wait to catch it others If you carry your childhood with you you income from is but facts. Project Code scores will be evaluated by entering aforementioned "stress-test" sentences. Any missing, incorrect, or extra unspecified functionality will result in a proportional or complete deduction of credit. Any compiler errors (e.g., gee or java is unable to compile the program code), as well as program runtime failures or infinite loops will result no credit for affected parts of the Program Code for this Project. Please verify that your submission is operational prior to final submission. The entire submission of Program Code and Project Report shall be your own individual original work. Any unauthorized use of shared, jointly written, or re-used code results in no credit for the entire Project.

Explanation / Answer

Given below is the Java code for the question. The program uses "SPARBEL" as the key which is mentioned in the question. You can change the key to the last name of the professor who gave you the assignment to verify that the output matches to the one given in the question.

Hope the answer helps. If it did, please don't forget to rate the answer. Thank you very much.


import java.util.Scanner;
public class VigenereCipher {
private static String encode(String text, String key)
{

String encoded = "";
int keyIndex = 0;
key = key.toUpperCase();
text = text.toUpperCase();
for(int i = 0; i < text.length(); i++)
{
char ch = text.charAt(i);
if(Character.isAlphabetic(ch)) //encode only alphabetic characters, retain everythign else
{
int txtNumericVal = ch - 'A'; //convert the character to a value in range 0-25
int keyNumericVal = key.charAt(keyIndex) - 'A';
int encodedVal = (txtNumericVal + keyNumericVal) % 26; //shift the text char by using key char
ch = (char)(encodedVal + 'A'); //convert back to ascii char
keyIndex = (keyIndex + 1) % key.length();
}
encoded += ch;
}
return encoded;
}
public static void main(String[] args) {
Scanner keybd = new Scanner(System.in);
String key = "SPARBEL"; //the key to be used
System.out.println("Enter the text to be encoded");
String text = keybd.nextLine();
String encoded = encode(text, key);
System.out.println("The encoded text is " + encoded);
}
}

output

Enter the text to be encoded

A HEALTHY ATITUDE IS CONTAGIOUS BUT DONT WAIT TO CATCH IT FROM OTHERS

The encoded text is

S WERMXSQ PTZUYOW XS TPRESVIFVW MMI DFOX HSXT KP GLLRH ZU JCGB OKIICK

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote