Posted on 2006-06-24
Last Modified: 2008-01-16
Hey, I am /pretty/ sure that this is possible, but not positive.

Say I have information froma program, and I want to save it so I can read it again later, I know I can and how to write it to a file, and I also already know how to read it from a file.

Now, what I was wondering, is it possible for me to make it so that this information is encrypted in some way, and even make the file not readable or something except by Java so that it doesn't get editted and nothing gets stolen from it.

Is it possible/practical to make my own encryption technique, how complicated would I have to make it.

Can anyone steer me in the right direction on this, I am making a custom program right now and saving stuff but it is so easy for someone to just edit it because normally I save stuff as .txt so its easy to read, even if I make something up and save it as like a .hgfa or something, you can still read it no problem if you open it right >_<, its kind of angering.

Thanks in advance.

Question by:simpsons17371
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 30

Expert Comment

ID: 16977605     File Encryption Tools

Quick Macros ( also has built-in encryption functions for encrypting/decrypting text.

Is this he type of stuff you're looking for?

Truecrypt is one of the best encryption programs. And it's free.
LVL 30

Expert Comment

ID: 16977609     Free Encryption / Cryptographic Software, Free On the Fly Encryption, Steganography, Free Disk Encryption Tools, Free Public Key Encryption Software (
LVL 14

Accepted Solution

hoomanv earned 70 total points
ID: 16977628
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.


Author Comment

ID: 16977651
Callrs, thats not quite what I am looking for, those seem to encrypt files once they exist.  I suppose I could make those work, but I was looking more along the lines of what hoomanv posted, something that encrypts while in java.

I don't seem to really follow how to put it in there though.  Basically I would be writing to a file, and then encrypting the information with a normal java encryption.  Couldn't anyone just use the unencryption class file to just unecrypt what I just did?

How hard is it would you say to make my own encryption technique?

Should I encrypt the text and then put it in a file and then maybe encrypt it again, or just encrypt the file?


LVL 14

Expert Comment

ID: 16977654
LVL 86

Assisted Solution

CEHJ earned 66 total points
ID: 16978229
Be careful how you store the key if you use encryption. If it's stored with the app, it would be reasonably simple to crack.

As far as stopping other people writing to the file is concerned, that's the remit of the OS, but you can make a call to it thorough Java with Runtime.exec. On XP, you could exec cacls, but see:
LVL 30

Assisted Solution

callrs earned 66 total points
ID: 16978889
From what I know of java, you can take someone's code & de-compile it into very readable code... so what you want may not be possible without a change of the Java language specification.

Or if you just want to read & write DATA to/from a file,  I see no reason why you can't encrypt it using Java. You can encrypt/decrypt using C++ for example, so just use some open source encryption code or some simple code off the net & build on that.     Encrypting a File or Stream with DES (Java Developers Almanac Example)     CodeGuru Forums - Java Encryption     Encrypt Sensitive Configuration Data with Java     Cryptography with Java > Cryptography with crypttool

Google for: java encrypt files
LVL 92

Assisted Solution

objects earned 66 total points
ID: 16980250
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 66 total points
ID: 16981190
>> Is it possible/practical to make my own encryption technique, how complicated would I have to make it.

I think it would be better to use a standard encryption technology - just make sure the key is secure :)

>> you can take someone's code & de-compile it into very readable code

You can use an obfuscator.

Assisted Solution

frube earned 66 total points
ID: 16985859
>> Is it possible/practical to make my own encryption technique, how complicated would I have to make it.

If you really wanted to write your own code for this then you can use an extremely basic encryption technique known as substitution which would involve writing a symmetric encryption algorithm. This is the process of swapping each letter in the alphabet with a different one with an integer key value. For example if you were to have a key of 3 then;

- every 'A' character would become 'D'
- every 'B' character would become 'E'
- every 'C' character would become 'F'

You probably encountered such techniques in basic puzzle books in maths class at school, so as you would imagine these techniques are not difficult to crack at all with the aid of a computer, but would be taxing for a human to decipher. If sensitive information such as passwords are being saved then this solution would not be appropriate at all, it would simply render the file incomprehensible to the human eye.

If you need to truly secure the file then you should look at the different options that Java provides in the JCE (Java Cryptography Extension) in the link below.

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question