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');
}
 can You please do this in Java Decrypt shift cipher The
following ciphertext was encrypted by a shift cipher: ycvejqwvhqtdtwvwu Write a program

The following cipher text was encrypted by a shift cipher: yovej qwwqtdtww Write a program in Java or in Python that will try all possible shifts. Your output should must be 11dw krxwirueuxwxV 25:xbudipvugpscsvut The plaintext wan: plaintextgooshere (replace plaintextgoethere 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) - (int) 'A'; else value = (int) - (int) 'a'; assert value >= 0 : "Value too low"; assert value 25)) throw new IllegalArgumentException(); return (char) (o + (int) 'a'); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!