Question
I have below question and I have my code as well. My program asks for all the command line user inputs. How can I fix
I have below question and I have my code as well. My program asks for all the command line user inputs. How can I fix my code to have a user input keyword, take an input plaintext file and output a ciphertext as file?
My Java program which asks command line inputs:
import java.util.*;
public class SubstitutionCipher { private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter a keyword: "); String keyword = scan.nextLine(); //scan.close(); String key = generateKey(keyword); System.out.println("Key: " + key); System.out.print("Enter a message to encrypt: "); scan = new Scanner(System.in); String message = scan.nextLine(); //scan.close(); String encryptedMessage = encrypt(message, key); System.out.println("Encrypted message: " + encryptedMessage); String decryptedMessage = decrypt(encryptedMessage, key); System.out.println("Decrypted message: " + decryptedMessage); } private static String generateKey(String keyword) { StringBuilder sb = new StringBuilder(); Set
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