File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

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

Gus Parker

Joined: May 10, 2009
Posts: 19

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.


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

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

Let's continue the discussion in this duplicate thread.
I agree. Here's the link:
subject: Help please: Encrypt, save to file, then decrypt later to read
It's not a secret anymore!