aspose file tools*
The moose likes Security and the fly likes need to encrypt files,suggest any tutorial Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "need to encrypt files,suggest any tutorial" Watch "need to encrypt files,suggest any tutorial" New topic
Author

need to encrypt files,suggest any tutorial

sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

hi all i am new to encryption.
my requirement is i need to encrypt file.
as of now i am able to encrypt
part of the code snippet is below



my doubt is people can de-compile and can know the "pwd" and "key" values and then they can decrypt files.
how can i secure "pwd" and "key" values also.
also suggest me any tutorial.

thanks you.

Sudheer
SCWCD, SCJP 5
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

You will need to expand on your requirements; much depends on who is doing the encryption and who is the recipient of the encrypted data. If these two are not one and the same then your best bet is to use public key cryptography such as RSA. The clear text is encrypted with the recipients public key obtained from a certificate published by the recipient. Decryption is performed by the recipient using his very very very private key.

If the same person will be doing both the encryption and decryption then you can still use public key cryptography but you cannot hold the password to the keystore in your code since anyone can decompile your code to find it. The password has to be memorised. Public key cryptography (say RSA) on files normally requires one to actually only encrypt a random symmetric algorithm (say AES) key using RSA and then use the symmetric algorithm to encrypt the data. For the details of one approach to this see section 13.6 of "Practical Cryptography" by Ferguson and Schneier published by Wiley.

Once you are having to memorise a password then a more simple approach is to use Password Based Encryption (PBE).

A good starting point for learning about Java cryptography is "Beginning Cryptography with Java" by David Hood published by Wrox.

Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237

hi James Sabre thanks for the reply.in my case i am the encryptor and decryptor.
presently i am using a string as key.there is no UI prompt for to enter password externally.
thanks again for the reply.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

sudheer kiran wrote:hi James Sabre thanks for the reply.in my case i am the encryptor and decryptor.
presently i am using a string as key.there is no UI prompt for to enter password externally.
thanks again for the reply.


1) Your code fragment does make much sense.
2) You don't need a keystore and you should probably use PBE.
3) Please please do some reading on the JCE. The "Beginning Crytography" would help you enormously and then reading http://download.oracle.com/javase/1.4.2/docs/guide/security/jce/JCERefGuide.html" target="_new" rel="nofollow">JCE Reference. It would be a mistake to just read the JCE reference.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need to encrypt files,suggest any tutorial