Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Java Encrypt/Decrpt program

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Java Encrypt/Decrpt program

    Cipher Class

    Create a class for the cipher with the following methods:

    default constructor: This constructor does nothing.
    constructor with two parms (key and list of rotation counts): Each parm is a string; the key is a string of 26 lowercase letters and the rotation counts is a string of 26 digits. The key should be converted to an indexed list of Characters and the rotation counts should be converted to an indexed list of Integers.
    encode: The encode method has one parm -- the plaintext string, and it returns the ciphertext string. Make a copy of the list that holds the key so that the original is not changed during encoding, because it will be needed for other calls to encode and decode. All non-letters, including blanks, should be left unchanged by the encode method. After you get your encode method working for lower case letters, make it work for uppercase letters too.
    decode: The decode method has one parm -- the ciphertext string, and it returns the plaintext string. To decode, start with the original key and counts, and perform the same rotations as when encoding.

    RefIndexedList

    You will write a shcopy method for the RefIndexedList. The shcopy method has no parms and returns a RefIndexedList. The shcopy method will make a shallow copy of the list; this means that the method will create new LLNodes to point to the list elements, but it will not create copies of the list elements. Thus the original list and the clone will point to the same objects.

    useCipher Class

    Your main method should do the following:

    read the key and rotation counts from a file; the first line should contain the key as a string of 26 lowercase letters and the second line should contain the rotation counts as a string of 26 digits
    create a cipher using this key and rotation count
    create a loop that prompts the user to enter a string (the plaintext); encode the plaintext and print the ciphertext, then decode the ciphertext and print the plaintext
    keep prompting the user to enter a string until the user wants to exit

    Any one willing to help me get through this assignment? I'm not asking for solutions, just help. anyone?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: Java Encrypt/Decrpt program

    The probability of receiving help goes up if you post what you have tried and ask a specific question.

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Encrypt/Decrpt program

    "The shcopy method will make a shallow copy of the list; this means that the method will create new LLNodes to point to the list elements, but it will not create copies of the list elements. Thus the original list and the clone will point to the same objects."

    Here is the method I wrote:
    public LLNode<T> shcopy()//creates shallow copy of the list, new nodes to point to list elements, but not
       //create copies of the list elements, so original list and new list will point to the same objects
       //Should then return the new RefIndexedList
       {
    	   LLNode<T> currentPos = null;
    	   LLNode<T> location;
    	   LLNode<T> previous;
    	   LLNode<T> shList = null;
    	   LLNode<T> newNode;
    	   //newNode.setlink(shList);
     
    	   return shList;
       }

    It compiles without errors but, I'm not sure if this is the correct way to create a shallow copy of a list or not, like if the nodes are instantiated
    correctly or not to make this method work.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,351
    Thanks
    49
    Thanked 2,204 Times in 2,177 Posts

    Default Re: Java Encrypt/Decrpt program

    What happens when the code is compiled and executed?
    Add some println statements to the code to print out the two lists so you can see what is in them and verify if the code is doing what you want.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Encrypt/Decrpt program

    this isnt a class with a main method tho. I have to make a cipher class then a useCipher class(this one would have the main method). I havent yet completed those two classes so i just need to know if This is how you'd make a shallow copy of a list or not?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,351
    Thanks
    49
    Thanked 2,204 Times in 2,177 Posts

    Default Re: Java Encrypt/Decrpt program

    How does that code make a copy of anything?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Encrypt Decrypt
    By dianac in forum What's Wrong With My Code?
    Replies: 15
    Last Post: April 14th, 2013, 11:01 AM
  2. Encrypt a text message
    By dianac in forum What's Wrong With My Code?
    Replies: 19
    Last Post: April 12th, 2013, 09:32 PM
  3. Replies: 2
    Last Post: June 4th, 2012, 11:40 PM
  4. [SOLVED] Unable to encrypt using AES 256bits
    By fuweng in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 5th, 2011, 07:44 AM
  5. Need Help for encrypt/decrypt.
    By superdhebz in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 17th, 2010, 12:17 PM

Tags for this Thread