GithubHelp home page GithubHelp logo

cs56-utilities-cryptography's Introduction

cs56-utilities-Cryptography

Run the project by typing

 ant run

javadoc website: https://ucsb-cs56-m16.github.io/cs56_utilities_cryptography_javadoc/javadoc/index.html

javadoc repo: https://github.com/UCSB-CS56-M16/cs56_utilities_cryptography_javadoc

project history

 YES | mastergberry | Implementation of 5 different types of string ciphers, both encryption and decryption.

Implementation of 5 different types of ciphers: -Shift Cipher -Affine Cipher -Vigenere Cipher -Bifid Cipher -RSA Cipher

Shift Cipher: Takes an integer a as the key. Encrypts the plaintext by shifting the characters along by adding the key to each of the characters and taking modulus 26

Affine Cipher: Takes 2 integers (a and b) as the key. Encrypts the plaintext by multiplying the character values by a and then adding b, taking modulus 26.

Vigenere Cipher: Takes a String s as the key. Encrypts the plaintext by applying the Shift Cipher to each character in the plaintext using the associated letter in the key as the key.

  e.g.
  plaintext = "random"
  key = "abc"

  Line up:	random
  	   	abcabc

  Giving:   rbpdpo

Bifid Cipher: Takes a String s as the key. Encrypts the plaintext by applying the Bifid Cipher to each character using a 25 letter 'key square' example of encryption using this 25 letter 'key square'

   1 2 3 4 5

1| p h q g m

2| e a y l n

3| o f d x k

4| r c v s z

5| w b u t i

e.g.
plaintext:   defend the east wall of the castle

step 1: row  323223 512 2245 5222 33 512 424522
        col  312153 421 1244 1244 12 421 224441

step 2:      32322 35122 24552 22335 12424 522
             31215 34211 24412 44124 21224 441

step 3:      3232231215 3512234211 2455224412 2233544124 1242421224 522441

step 4:      f f y h m  k h y c p  l i a s h  a d t r l  h c c h l  b l r

RSA Cipher: Two keys are automatically generated. Encrypts plaintext using an RSA Algorithm. First the public key is used for encryption then the private key is used for decryption.

Format of Input for GUI:

General: No spaces are to be used in the key or plaintext input fields. Capital letters can be used but will be translated to lowercase prior to any cryptographic operation being performed on them.

Shift Cipher: Key text field should contain a single integer within the range of 0 to 25 inclusive.

Affine Cipher: Key text field should contain two integers seperated by a single space, with the first integer being with the range of 0 to 25 inclusive and the second integer being greater than 0. If decrypting, the additional condition that the first integer must be a coprime with 26 also holds.

Vigenere Cipher: Key text field should contain a string of characters.

Bifid Cipher: The Plaintext can have uppercase or lowercase letters and spaces but numbers will result in an error. The key has to have at least one captial letter and no numbers. The key setter will parse out all non capital letters.

RSA Cipher: The plaintext can have any letters uppercase or lowercase, but no numbers or symbols. The key must be generated automatically because they must be different large prime numbers.

W16 final remarks:

-Most of ciphers have not been changed and have only been implemented differently.

-Now you can input more than one string with spaces in between.

-You can now use all the ciphers at once to encrypt one string.

-After each cipher, the program will write to a file called "output.txt"

The program itself takes in an input string and input key to encrypt or decrypt the input string. Each encryption cipher has already been defined and most of the work will be in the Cryptography.java file. There is a lot of opportunity to refactor some of the JButton codes.

This is the picture included in welcome window and is a pictorial demonstration of general usage of application. alt tag

M16 final remarks:

  1. The methods of encryption and decryption have not been changed.
  2. Now, you can generate random keys.
  3. A new GUI has been added, which have one big input text area and output text area, four seperate key input areas.
  4. Now, you can look at the javadoc on website.
  5. The keys and ciphered text will be saved to a file, default named output.txt.
  6. You can decide where the output file will be saved
  7. The methods of anonymous ActionListener class are factored out to a class called GUIActionMethid.
  8. The lambda function has been used on implementing anonymous ActionListener.
  9. You get another window for all ciphers. The class AllCipherGUI is for that window.
  10. If you want to modify or add new function for each widget, for example, to edit error message, you may look at the GUIActionMethod class.
  11. If you want to add new widget or modify the GUI, you may look at the CryptographyGUI class or AllCipherGUI classes.
  12. If you want to edit or add algorithm for ciphers, you may look at the classes AffineCipher, ShiftCipher...

F16 final remarks:

  • Bifid cipher has special cases for the letters I and J
  • Added RSA Encryption window
  • GUI has been updated with a new look and feel
  • You can now choose your save folder from a pop up
  • You an choose an input file to put into the plain text window
  • A welcome window has been added
  • Added a picture explanation in the README.md file
  • Added a few comments in the code for clarity
  • Added specific error messages
  • Tip: Follow the methods that are called when a button in the GUI is pressed to get an understanding of how the classes interact with each other.

F17 Final Remarks:

Changes made

  • The welcome screen was updated to reflect the implementation of a fifth cipher, RSA. The jpg in the tutorial was updated to reflected the reorganized GUI.
  • The RSACipher algorithm works to encrypt and decrypt, as well as generated public and private keys as strings. This change has been addressed in the GUI and a test class has been made for RSA.
  • NOTE:When creating the new RSA cipher, we utilized the Cryptography and KeyFactory APIs. Even though we recognize that the Cipher classes share commonalities and should be refactored, we implemented the new RSA cipher in the same style as the first four. This way, future generations can refactor all five ciphers in the same way. The previously created cipher classes could make use of APIs when refactoring.
  • The GUI window is now resizable
  • The tutorial can now be displayed at any time by using the newly implemented tutorial button.
  • When switching from encrypt to decrypt, the ciphered text will automatically be pasted into the text area on the right, which is now the "ciphered text" area, so that way the user doesn't have to copy/paste it manually. When switching back to plain text, the deciphered text from the right side will be pasted into the "plain text" box on the left.
  • The AllCipherGUI now incorporates the RSA cipher so that way all five ciphers can be executed at once.

Issues we did not address

  • We did not implement the QUAD cipher, where a string can be run through a series of four ciphers. Instead, we fixed the current bugs instead of adding enhancements.
  • We did not implement the ability to have numbers in the input, except in the RSA cipher, because the RSA cipher relies on the Cryptography API which is able to handle numbers.

Room for improvement/future bugs and Issues

  • Add more detailed error messages, some error message dialogs do not match up with the actual error
  • The code needs to be documented better, to better understand how it is organized. There was previously many blocks of commented-out code that should have been deleted.
  • There is little use of design patterns/inheritance/APIs. The overall code could be refactored and reorganized. For example, the Ciphers contain the same methods but do not use any inheritance. The Factory design pattern could be used to generate Keys and KeyPairs. The Java API already has some cryptography utilities built in, so we utilized those when creating the new RSA cipher

cs56-utilities-cryptography's People

Contributors

aryamandas avatar ddu82164 avatar hannavigil avatar keithlo avatar kmahorker avatar leifdreizler avatar marioinfante avatar mastergberry avatar peffedu avatar rarielle avatar tektonbuilds avatar xiaoheh avatar zhanchengqian avatar

Watchers

 avatar  avatar  avatar

cs56-utilities-cryptography's Issues

Make number input possible

Originally the App doesn't support number inputs, but it should be better if you can just type in "1201" instead of "one two zero one". And also the decryption method needs to correctly output to strings like "1201" instead of "one two zero one".

(est. 200 pts)

Use gh-pages to publish javadoc

The current build.xml creates javadoc to a CSIL account. Change it to a github page URL, as did in previous labs

Estimate: 150 pts

Substitution Cipher

Add in substitution cipher along with test class and javadoc comments.

~estimated 250

Ciper TextFields are Not Visible on GUI

The main GUI frame no longer displays the text fields that display the ciphered texts for the different algorithms in the program.

Fix the window display so that the ciphered texts are visible (currently, they are shoved out to the left and resizing the window manually does not appear to resolve the issue)

150 pts

Encrypt with all methods

Issue: Have an option to encrypt or decrypt the plaintext using all the encyption methods and display all of them as such; Affine: dekfjhe, Shift: nckdjfd, Vignere: skjcfns

Write to file

Issue: Write to a file the plaintext that is to be encrypted, the key, and the encrypted text in one entry. This entry will list the kind of cipher as well and work for the other way around. The file will be written as the program is being run and be finished once the user closes out of the program.

Fix RSA Cipher algorithm

Currently the algorithm isn't working. The majority of the algorithm is there, however, it does not work correctly. The cipher is based off of the algorithm that is described in the page linked below:
RSA (algorithm)

Confusing Stack Trace Error

Stack trace is printed for a case where an error dialog box is shown. This is confusing for the developers who expect a stack trace when a run-time error occurs, rather than when a dialog box prevents the user from taking this "dangerous" action. Reproduce error by switching to decrypt mode and attempting to keyGen.

Trace:
java.lang.Exception
[java] at edu.ucsb.cs56.projects.utilities.cryptography.GUIActionMethod.checkMode(GUIActionMethod.java:49)
[java] at edu.ucsb.cs56.projects.utilities.cryptography.GUIActionMethod.BifidGenKey(GUIActionMethod.java:487)
[java] at edu.ucsb.cs56.projects.utilities.cryptography.CryptographyGUI.lambda$go$5(CryptographyGUI.java:292)

Improve All-cipher function

When click All-cipher, there will be a pop-up windows where you have two columns
on the left one input windows in which you put plaintext
and on the right are four keys input windows so that this makes more sense to the user.

(est. 250 pts)

Assess project as part of lab07

Since ddu82164 switched into this repo after lab05, making an assessment described in the directions of Lab05 and saving it as w16_lab07.md is worth 200 points.

200 pts.

Decryption

Add in decryption for each of the ciphers along with the relevant changes to the GUI.

~estimated 120

Output file

Add into interface option to specify where the output file will be saved and what the output file will be called.

Clean Button doesn't clear RSA

The clean button removes the keys from all the text fields except for the RSA. Clear the RSA key text field when the clean button is pressed.

Make ciphertext appear in a an area that can be copied/pasted, general GUI improvements.

(1) Package cleanup---separate the GUI from the Ciphers:

Separate the GUI and the ciphers into separate packages:

edu/ucsb/cs56/projects/utilities/cryptography/ciphers
edu/ucsb/cs56/projects/utilities/cryptography/demos

Move the GUI program into edu/ucsb/cs56/projects/utilities/cryptography/demos

Presumably other kinds of demos could go in there as well. (e.g. command line program to convert an entire file from plaintext to ciphertext, and back---but that's for another issue.

(2) When the ciphertext appears in GUI, it is not in a part of the GUI that can be copied/pasted.

Putting it in a widget that allows the contents to be copied.

In addition, make error messages in GUI more user friendly. At the moment, error messages refer use to the "README.md file" for advice on the format of inputs. Instead, put the advice directly into the error messages.

(3) Finally, consider other ways of making the gui easier to figure out. For example, consider having separate input fields for the shift cipher, affine cipher and vignere cipher keys, with the buttons beside each one. Or, propose your own design. Play with the interface for a while and decide what would be an improvement to make it easier for first time users, then do that.

~estimated: 300

Make GUI resizable

The length and width of all the swing component classes are hard coded in the main GUI. Refactor code so that the window is scalable

GUI creation

Create a GUI in which you can input a String, choose the form of encryption and see the outputted encrypted String.

~estimated 180

RSA cipher not on main page and TextFields are too large

It gets confusing when there is a separate window for the RSA cipher and all the other ciphers are on the main page. The functionality for the RSA cipher should be included on the main page. The text areas are too large and need to be sized down to make the GUI look better and allow for more room for more ciphers. Center Panels need to be refactored to be aligned and relative to one GridBagLayout, not multiple.

(est. 150)

Make the encryption work

From my testing, it does not work. It could be that the README does not have proper instructions as to how to do it, but either the README needs to be updated or the implementation needs to change

Mismatching Error Dialog Boxes

When errors occur, the wrong labels and information about the error are shown. (i.e. Error with RSA has Dialog box title: Affine Cipher, Error with Key for RSA says the text input has an error)

Define a QUAD encryption method

User need to input four keys and just one string. The string will go through the encryption process as following: first Shift Cipher, then Affine Cipher, then Vignere Cipher and then Bifid Cipher.
The output should be a string that has been encrypted four times using four cipher machines.

(est. 200 pts)

Change the information page

Change the information page (the one pops up when clicking info), correct the existing typos, add more examples to illustrate how to correctly use the software.

(est. 50 points)

Be More Specific on Bifid Cipher

The key HAS to include at least 1 uppercase letter. Update both the cipher's information in the Info button, as well as when there is incorrect input and the user has clicked on the Bifid Cipher button.

~estimated 50

Brand new GUI (greatly improve the old one)

Divide the GUI into few columns, the leftmost one has a text box that you can input strings,
to the right are four key boxes that you can input keys. next to each key box you have a button to generate random keys and also another button to execute. Rightmost is a output text box.
Basically redesign the old GUI to be a brand new one that makes more sense.

(est. 250 pts)

Improve input textbox function

Make the textbox bigger so that it can take several paragraph of messages
(you also need to make the output textbox bigger in order for this to work)
Also make it scrollable.

(est. 200 pts)

Refactor Cipher Classes

Cipher classes perform a similar function and should use a super class and implement inheritance to factor out the common code between ciphers. Rewrite existing ciphers to extend Cipher super class.

Make more specific error message

Make more specific error message. For example, if the user types letters for the key of a cipher which can only take integer key, the program may prompt "the cipher cannot take integer as keys, use letters instead." (estimates 100 points);

Read in from file

Be able to read in plaintext, key, and encryped/decrypted key from input text file.

Generate a key automatically

Add an option that the user doesn't need to read the instruction and pick an appropriate key by himself, but instead a key is randomly generated by the system and stored somewhere (i.e. a temporary file, or show the key on screen when the user clicks a certain button, depending on the actual design for this usage). Also provide the decryption method corresponding to where the key is automatically stored.

Estimated: 250 pts

Make the GUI look better

  1. Make the Encryption/Decryption button into a slide button. (like you can slide it to one end to switch it to Encryption, the other end to switch it to Decryption)
  2. Change the “plaintext” label to “ciphered text” when in decryption mode so notify user about the current mode
  3. Change the position where the app shows up from startup

(est. 250 pts)

Add ability to switch to encrypt mode from dialog box

If you are in decrypt mode and try to generate a key, an error shows up that you must be in encrypt mode. Include a button on the dialog box, that says "Switch to Encrypt Mode", that will directly change the mode for you.

Decrypt current string

Decrypt the encrypted string immediately rather than having to reenter the string and switch to decryption.
~Estimated 200 points

Add "open" and "folder" buttons

Add "open" button that gives a window that let you choose whatever address you want to save your text file, instead of having you type the address out in "save address". Like those windows that you have when you are trying to upload files as attachment of emails. Also add "folder" button that brings up the save location folder so that user can access it directly in the OS. (estimates 150 points);

Make a new welcome page for the application

Make a new welcome page for the application. For example, when the user opens the app for the first time, he/she will be prompted with this new window "welcome" and in this window, there are several pages. For example the first page is an introduction about the app, and second page would be example of how to use shift cipher, the next page would be how to use affine cipher, and so on... Make sure that this welcome page has a checkbox that says "open me everytime the app starts". If deselected, the welcome page will not appear on the next startup. (estimates 150 points);

AllCipherGUI.java needs to incorporate RSA

The class to use all ciphers at once in a new window needs to incorporate the RSA cipher which has been implemented. The GUIActionListener which the AllCipherGUI depends on must have respective methods updated to execute all ciphers.
est (250)

Tidy up Repo a bit more

In addition to #7 go ahead and add some screenshots to the README.md once you are done.

~Estimated 50 points

Allow for strings input with spaces

The strings right now require continuous text input rather than a sentence with spaces. Code the encryption methods such that the input allows for strings with spaces. There can be ways to implement the methods in such a way that they keep track of the spacing between words.

Tutorials

Including instructions in the GUI on how to enter plaintext and keys is important.
~Estimated 200 points

Project Structure

Create the project, setup build.xml and structure. Add three cipher classes with associated test classes. Make javadoc comments.

Have useful Readme.md file!

~estimated 300

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.