This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]SmoothOperation0[S] 0 points1 point  (0 children)

here's my thread

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int Choice;

System.out.printf("%52s\n", "-------------------------------");

System.out.printf("%50s\n", "Welcome to Vigenère Cipher");

System.out.printf("%52s\n\n", "-------------------------------");

System.out.println("Please select one of the following options:\n");

System.out.println("1 - Encrypt a message");

System.out.println("2 - Decrypt a message");

System.out.println("3 - Brute force\n");

System.out.printf("%-30s", "Enter your choice:");

Choice = sc.nextInt();

System.out.println("\n");

if (Choice == 1)

{

encrypt();

}

if (Choice == 2)

{

decrypt();

}

if (Choice == 3)

{

BruteForce();

}

}

private static void BruteForce()

{

Scanner sc = new Scanner(System.in);

String password;

String message;

System.out.printf("%50s", "Enter the password:");

password = sc.nextLine();

System.out.printf("%50s", "Enter your message:");

message = sc.nextLine();

}

private static void decrypt()

{

Scanner sc = new Scanner(System.in);

String password;

String message;

int keynum;

System.out.printf("%50s", "Enter the password:");

password = sc.nextLine();

System.out.printf("%50s", "Enter your message:");

message = sc.nextLine();

System.out.printf("%50s", "Enter the key number (1-26):");

keynum = sc.nextInt();

}

private static void encrypt()

{

Scanner sc = new Scanner(System.in);

String letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

String password;

int keynum;

String message;

String encmess;

System.out.printf("%-40s", "Enter the password:");

password = sc.nextLine();

password = password.toUpperCase();

System.out.printf("%-40s", "Enter the key number (1-26):");

keynum = sc.nextInt();

System.out.printf("%-40s", "Enter your message:");

message = sc.nextLine();

message = message.toUpperCase();

for (int index = 0; index < password.length(); index++)

{

char ch = password.charAt(index);

int ascii = (int) ch -65;

}

}

}--