Caesar Cipher Repeating Key Program
Description
This program uses the Caesar Cipher with repeating key algorithm to encrypt a message.The keys are organized with a queue data structure.
Use Queue interface and LinkedList class in Java Collections to create the queue.
Associated Concepts:
Queue
Java Collections Framework
Java Collections Framework
Algorithm:
main method:
encrypt method definition:
Create a String message with the hard-coded values.
Create an array with the hard-coded integers as keys.
Call encrypt() method and print the returned string.
Create an array with the hard-coded integers as keys.
Call encrypt() method and print the returned string.
encrypt method definition:
Create a queue using Queue interface and LinkedList class in
Java Collections Framework.
Load the keys in the array into the queue.
Declare a String variable to store the result.
In a loop:
After the loop ended, return the result.
Load the keys in the array into the queue.
Declare a String variable to store the result.
In a loop:
Remove the front key in the queue.
Retrieve each character in the original message.
Encrypt the character with the key.
Add the encrypted character to the result.
Add the key to the rear of the queue.
Retrieve each character in the original message.
Encrypt the character with the key.
Add the encrypted character to the result.
Add the key to the rear of the queue.
After the loop ended, return the result.