Solved

Encryption

Posted on 2006-06-24
12
509 Views
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.

Mark
0
Comment
Question by:simpsons17371
12 Comments
 
LVL 30

Expert Comment

by:callrs
Comment Utility
http://www.snapfiles.com/Freeware/security/fwencrypt.html     File Encryption Tools

Quick Macros (quickmacros.com) 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.
0
 
LVL 30

Expert Comment

by:callrs
Comment Utility
http://www.thefreecountry.com/security/encryption.shtml     Free Encryption / Cryptographic Software, Free On the Fly Encryption, Steganography, Free Disk Encryption Tools, Free Public Key Encryption Software (thefreecountry.com)
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 70 total points
Comment Utility
0
 
LVL 1

Author Comment

by:simpsons17371
Comment Utility
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?

Mark

0
 
LVL 14

Expert Comment

by:hoomanv
Comment Utility
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 66 total points
Comment Utility
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:

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
0
 
LVL 30

Assisted Solution

by:callrs
callrs earned 66 total points
Comment Utility
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.

http://javaalmanac.com/egs/javax.crypto/DesFile.html     Encrypting a File or Stream with DES (Java Developers Almanac Example)
http://www.codeguru.com/forum/archive/index.php/t-40117.html     CodeGuru Forums - Java Encryption
http://www.devx.com/Java/10MinuteSolution/21385     Encrypt Sensitive Configuration Data with Java
http://www.phptr.com/articles/article.asp?p=170967&seqNum=10&rl=1     Cryptography with Java > Cryptography with crypttool

Google for: java encrypt files
etc.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 66 total points
Comment Utility
0
 
LVL 30

Assisted Solution

by:mayankeagle
mayankeagle earned 66 total points
Comment Utility
>> 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.
0
 
LVL 2

Assisted Solution

by:frube
frube earned 66 total points
Comment Utility
>> 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.

http://java.sun.com/j2se/1.5.0/docs/guide/security/CryptoSpec.html
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now