Java Encryptor - strange output
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.
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!
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.
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.
Last Post: 06-14-2006, 03:16 PM
Last Post: 05-13-2005, 06:46 AM
By Mike Tsakiris in forum .NET
Last Post: 10-04-2002, 05:32 PM
By Anonymous in forum Java
Last Post: 01-31-2002, 11:08 PM
By JJ in forum Enterprise
Last Post: 07-06-2000, 04:50 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center