Question
can You please do this in Java Decrypt shift cipher The following ciphertext was encrypted by a shift cipher: ycvejqwvhqtdtwvwu Write a program in Java
can You please do this in Java
Decrypt shift cipher
The following ciphertext was encrypted by a shift cipher:
ycvejqwvhqtdtwvwu
Write a program in Java or in Python that will try all possible shifts. Your output should must be
1:zdwfkrxwirueuxwxv
...
25:xbudipvugpscsvuvt
The plaintext was: plaintextgoeshere
(replace plaintextgoeshere with the actual recovered plaintext).
Note 1: your program does not have to decide what the correct output is. Once you have determined what the plaintext was, update your program to print out this last line.
Note 2: In order to receive full credit, your output MUST EXACTLY match the format printed above (including proper whitespace, etc.)
If you use Java, you may use the following code fragments in your program:
/**
* @return the ordinal value of a character c.
* This function disregards case, but does preserve it.
* Ordinal values are a=0, b=1, ..., z=25
*
* Preconditions: only valid characters are a-z and A-Z
*/
public static int charToOrd(char c) {
int value;
if (Character.isUpperCase(c))
value = (int)c - (int)'A';
else
value = (int)c - (int)'a';
assert value >= 0 : "Value too low";
assert value return value;
}
/**
* @returns the lower-case character matching the ordinal value o
* Ordinal values are a=0, b=1, ..., z=25
*
* Preconditions: only valid values are 0-25 (inclusive)
*/
public static char charToOrd(int o) {
if ( (o 25) ) throw new IllegalArgumentException();
return (char)(o + (int)'a');
}
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