APCS – Cipher Project

What Cipher Am I Doing

I’m making the columnar cipher. In short what this does it it will take a string, convert the string into a x*y size grid, shuffle it somehow, and then convert the new grid back into a string, and then return that. To shuffle my grid I reversed it, however there are a multitude of other methods on how to accomplish this.

Video

Imports

ArrayList:

ArrayList is an alternative array structure to the standard java array. I like it more and it works well with my programs

List:

I used this as a supplement to create my columns. Can be seen when I created the list of lists of characters.

PrintWriter:

Its a better printer. You can print arrays and see all their indexes and it just makes debugging easier.

Collections:

I used collections to reverse my arraylist. You can also use it to sort and shuffle arraylists which I used in elevens lab.

Misc swing imports:

Used to make my GUI.

Use of loops

For this project I used for loops entirely, although while loops would have also been a feasible, although convoluted, method. Outside of the GUI I didn’t use a single while loop, as it would have complicated things more than they would’ve needed to be. I used for loops mainly to construct and deconstruct the grid-

// puts the string into columns and fills the remainder with 'x'
 int o = 0;
 for (int i = 0; i < y; i++) {
     for (int z = 0; z < x; z++, o++) {
         if (o < s.length()) {
             column.get(z).add(s.charAt(o));
         } else {
             column.get(z).add('x');}}}

-more examples like this can be seen in my encrypt and decrypt classes, and for loops formed the backbone of keeping this cipher dynamic and functional.

Conclusion

In conclusion this cipher was, for the most part, successful. It works as it should and my crude GUI serves its purpose. However I do think I could have made it a little more complicated than I did. Overall it was fun to code, and I’m excited to move onto harder challenges.

 

Leave a Reply

Your email address will not be published. Required fields are marked *