This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Help please: Encrypt, save to file, then decrypt later to read Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Help please: Encrypt, save to file, then decrypt later to read

Gus Parker
Greenhorn

Joined: May 10, 2009
Posts: 19
Hi,

I'm new to encrypting data in JAVA, have spend a few days reading up about it
and trying several methods, the methods I have got to work have pretty weak encryption.

The code below is one I'd really like to get working properly but seem to be having trouble with

Any point in the right direction, or what I am doing wrong would be great help.

Cheers



This code - Works fine.



The trouble is I want to write the encrypted message into a text file, then read it again
from another class.

So I tryed this below, tryed break down the key, then trying to rebuild the key (so I can
use it in another class once I get this right)

As you can see down the bottom, the first "Text Decryted : " Message will only show the
message it originally generate for this instance.

BUT the second one fails when it trys to Decrypt the code I have given it from class, the key
I've used with the 2nd one I have taken from another instance of running the program (the one
were I got the encrypted message to be decryted)




Do you think I'm going about this the right way, am I getting warm with it?

Is there a better way to be doing this?

Basically I want to take a string, encrypt it, save that to a text file, then decrypt it to read it
later on.

Any help would be fantastic,

Cheers, good day to you :-)

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41079
    
  43
Please do not post the same question to multiple forums: CarefullyChooseOneForum

Let's continue the discussion in this duplicate thread.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help please: Encrypt, save to file, then decrypt later to read
 
Similar Threads
Help please: Encrypt, save to file, then decrypt later to read
3DES encryption and decryption
Java Cryptography Extension giving me different result every time
Cryptography - deciphering doesn't yield the same text
What broke between 1.4 and 1.6 for decryption?