Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void EncodeText()
- {
- Random rand = new Random();
- Scanner input = new Scanner(System.in);
- String alphabet[] = {"a","b","c","d","e","f","g","h","i","j","k","j","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
- int key[] = new int[4];
- boolean isKeySet = false;
- // Generate Random key.
- if(!isKeySet)
- {
- for(int i = 0; i < key.length; i++)
- {
- key[i] = rand.nextInt(26);
- System.out.print("Key["+ i + "] - " + key[i]);
- }
- }
- // We Enter text to be encoded and pull the corresponding positions out of the array.
- System.out.print("\nEnter Message : ");
- String plaintext = input.next();
- String parts[] = plaintext.split("");
- //int index[] = new int[parts.length];
- // We want to compare the alphabet to parts and pull out the position of any matches
- // Iterate tru the array
- // compare both arrays
- // get position and store them in an array?
- for(int x = 0; x < alphabet.length; x++)
- {
- for(int y = 0; y < parts.length; y++)
- {
- if( alphabet[x] == parts[y] )
- {
- //index[x] = y;
- System.out.println("Match Found : letter [" + alphabet[x] + "]");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment