Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rebelcypher;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class RebelCypher
- {
- public static void main(String[] args) throws FileNotFoundException
- {
- Scanner sc=new Scanner(new File("data.txt"));
- String stolen=sc.nextLine();
- String encrypted=sc.nextLine();
- String decode=sc.nextLine();
- String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
- String decodedMessage="";
- char[] encryptedArray=encrypted.toCharArray();
- char[] decodeArray=decode.toCharArray();
- char[] alphabetArray=alphabet.toCharArray();
- String newAlphabet="";
- for(int c=0;c<27;c++)
- {
- for(int x=0;x<stolen.length();x++)
- {
- if(stolen.indexOf(alphabetArray[c])!=-1)newAlphabet+=encryptedArray[stolen.indexOf(alphabetArray[c])];
- else newAlphabet+='.';
- break;
- }
- }
- for(int c=0;c<decode.length();c++)
- {
- if(newAlphabet.indexOf(decodeArray[c])==-1)decodedMessage+='.';
- else decodedMessage+=alphabetArray[newAlphabet.indexOf(decodeArray[c])];
- }
- System.out.println("Regular Alphabet: "+alphabet);
- System.out.println("Decoded Alphabet: "+newAlphabet);
- System.out.println("Message to Decode: "+decode);
- System.out.println("Decrypted Message: "+decodedMessage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment