• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need to encrypt files,suggest any tutorial

 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic