
As always, try experimenting with the code to see what happens when you change things. The GUI interface is a bit beyond the scope of this article, but feel free to look it over.

The encryption code is relatively simple (click to enlarge):ĭecryption is very similar we simply switch the keys and values in the hashmap so that everything is in reverse. In later posts, we will write more secure encryption algorithms. Someone who knows you are using a Caesar Cipher encryption could easily break it by hand, since there are only 26 possibilities. Note that this encryption algorithm is not very secure. Assuming my code isn't buggy, it should then display the secret message in plain text! When your friend receives the message, they put the ciphertext into the top box with the agreed "Shift Factor", then press "Decrypt". If you wanted to send a secret message to your friend, you would input the message into the top box, enter a shift factor (both people need to agree on this number), then push "Encrypt". Here is how you would use the app to do that: So, if we wanted to encrypt "ABC" with a shift of 1, then we would shift all the letters one to the right, yielding "BCD". As a review, this cipher works by shifting each letter by 0 to 25 times. This program uses the Caesar Cipher algorithm, which we discussed last month. Just click here to download it and here to view and/or download the source code. The program will we use is my Caesar Cipher app.


If you are new to Java, check out Matthew's Learn Java: Part One for a quick beginner's lesson, or check out some of the Java tutorials directly on Oracle. Today, we are going to combine what we learned from the Introduction to Cryptography article with our Java programming skills.
