DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Nov 2002

    Java Encryptor - strange output

    Hey all,

    I hope someone can shed some light on this small problem I have. Ok, here goes. I love to do cryptoquotes (or celebrity cyphers, whatever your newspaper calls them) and so does my fiance. I like to send her emails with small cyphers in them but hate having to change all the letters manually.

    I thought it would be fun to make a real quick program in java to do this for me, automate the whole process of encrypting and decyphering. I stopped after i made the encryption part because it wasnt outputting what it should have been.

    I have attached a zipped folder of the three files i have and at the bottom of cryptoquote.java i have what it does output and what it should output. I also placed some code in the method that encrypts the input string to output each step since i lack a compiler that lets you stop and walk through each line of code.

    Please any help on this problem would be greatly appreciated. I know the code is pretty rough but I have yet to refine it all...took me 15 minutes to write it all so I am open to any critiquing.
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2005
    the Netherlands
    Hi there, I browsed you code but stopped to find the error. Since you're still in the beginning of your project I think it would be wise to do it a bit different. It's better to work wth char's instead of String's when you're doing this kind of thing.
    I attached an example I coded for you. Please bare in mind that there are a lot of flaws in the performance of the encryption, but it's very simple and I think you'll only be using it to encrypt small messages, so you'll be ok. And you can, of course, modify it to your wishes!
    It reads and writes the messages and your encryption key from file instead of a console (more conveniet I think).

    Do post again if you're having trouble with decrypting messages from your fiance (wish my girlfriend found this interesting...). That's where the real fun begins!

    Good luck.
    Attached Files Attached Files

  3. #3
    Join Date
    May 2005
    It dosnt work because of this


    the above code is saying, IF ( checker IS 1 letter above A )

    what you need to have is this


    this says , IF ( checker IS equal to a )

    the way the compareToIgnoreCase method works is weird, it returns a negative if the letter is lower, a zero if its the same, or a positive if its higher.

    scroll down to the compareToIgnoreCase method and read its description.

    so change all the ones to zeros, and it will work. this had me confused at first too, but after i looked at the API i noticed this method dosnt go by 0 or 1.

  4. #4
    Join Date
    Nov 2002

    Makes sense now...

    Hey thanks, now that you say that it does ring a bell. I have taken quite some time off from coding and I totally forgot about that. Thanks for your help in solving this little problem, from now on I will be sure to check the API just to make sure its not a simple fix like that...haha, i feel silly after reading the solution.

    Thanks again,

Similar Threads

  1. Replies: 2
    Last Post: 06-14-2006, 03:16 PM
  2. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  3. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM
  4. Replies: 0
    Last Post: 01-31-2002, 11:08 PM
  5. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 04:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.