Question: Write a program to complete the followings: 1. Use a Caesar 16-shift cipher to encrypt the plaintext Thursday. 2. Use a Caesar 8-shift cipher to

Write a program to complete the followings:

1. Use a Caesar 16-shift cipher to encrypt the plaintext "Thursday".

2. Use a Caesar 8-shift cipher to decrypt the ciphertext "amkzmb umaaiom"

3. Use brute-force attack to recover the cipher text of "HDVB WR EUHDN"

Your program outputs should look like the following screen shot:

 Write a program to complete the followings: 1. Use a Caesar

import java.util.*; import java.io.*;

public class CaesarCipher { // encryption public static String encrypt(char c, int key_int) { String res = "";

// make it upper case c = Character.toUpperCase(c);

if (c 'Z') { res += c; // do nothing } else { res += (char) ((c + key_int - 'A') % 26 + 'A'); }

return res; }

// decryption public static String decrypt(char c, int key_int) { String res = "";

// make it upper case c = Character.toUpperCase(c);

if (c 'Z') { res += c; // do nothing } else { res += (char) ((c - key_int + 26 - 'A') % 26 + 'A'); }

return res; } // brute force attack public static void bruteforce(String text) { text = text.toUpperCase();

// invoke decrypt method... }

public static void main(String[] args) throws IOException { System.out.println("Encrypted message: " + encrypt('T', 16)); System.out.println("Decrypted message: " + decrypt('a', 8)); System.out.println("Brute Force attack:"); bruteforce("HDVB WR EUHDN");

} }

Bluel: Terminal Window-1 Caeser Options Encrypted message: JXKHITOO Decrypted message: SECRET MESSAGE Brute Force attack Recovered message (key- 0): HDVB WR EUHDN Recovered message (key1) GCUA VQ DTGCM Recovered message (key2) FBTZ UP CSFBL Recovered message (key= 3): EASY TO BREAK Recovered message (key4) DZRX SN AQDZJ Recovered message (key 5): CYQW RM ZPCYI Recovered message (key6) BXPV QL YOBXH Recovered message (key-7): AWOU PK XNAWG Recovered message (key 8) : ZVNT OJ WMZVF Recovered message (key- 9): YUMS NI VLYUE Recovered message (key-10): XTLR MH UKXTD Recovered message (key-11): WSKQ LG TJWSC Recovered message (key-12) VRJP KF SIVRB Recovered message (key-13): UQIO JE RHUQA Recovered message (key=14): TPHN ID QGTPZ Recovered message (key=15): SOGM HC PFSOY Recovered message (key#16): RNFL GB OERNX Recovered message (key#17): QMEK FA NDQMW Recovered message (key-18) PLDJ EZ MCPLV Recovered message (key 19) OKCI DY LBOKU Recovered message (key 20): NJBH CX KANJT Recovered message (key 21): MIAG BW JZMIS Recovered message (key 22) LHZF AV IYLHR Recovered message (key 23): KGYE ZU HXKGQ Recovered message (key 24): JFXD YT GWJFP Recovered message (key-25): IEWC XS FVIEO Can only enter input while your programming is

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!