Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java encryption

 
great veera
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
can anyone pl give me an idea for encrypting a file in java,
 
Patrick O'Hara
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need the Java Cryptography Extension (JCE). There is an implementation of JCE called Cryptix which you can find (http://www.cryptix.org/products/index.html).
There are many schemes to choose from.
There is a pretty good introduction to cryptography here (http://www.ssh.fi/tech/crypto/intro.html).
Hope that helps.

------------------
Pat O
pdohara@techneex.com
 
Fredrik Safstrom
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you looking for real encryption with keys etc. or just a quick and easy way to encrypt messages???
I have a small class that will let you encrypt text messages (doesnt work on binary files), let me know if you are interested...
/Bamse
 
Ramamoorthy
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Fredrik Safstrom:
Are you looking for real encryption with keys etc. or just a quick and easy way to encrypt messages???
I have a small class that will let you encrypt text messages (doesnt work on binary files), let me know if you are interested...
/Bamse

Dear bamse,
I am interested to know from you the encryption of user inputs.
For example i am getting two fields from the user namely
username and password and i want to send both to the server in encrypted form...so that the same can be decrypted at the server end and compared with the database.
Kindly advise me,if you have solution for that.
If your solution is similar to above ,kindly send me your application,which will be of very much helpful to me.
Regards,
Rama moorthy
Please send your reply to ramamoorthy90@hotmail.com
 
Fredrik Safstrom
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rama,
Here is the class itself:

It's quite simple to use, here is one example;

You can supply the constructor with a code-key if you want, otherwise the codekey will default to 'Q'.
If you want to add upp characters that are specific for your language in the alphabeth string, my version have some Swedish characters in there. The class will only encrypt/decrypt characters in the alphabeth string, if a character cannot be found, it will be ignored and left as is...
Have fun.
/Bamse
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramamoorthy,
Please review the JavaRanch naming policy and consider re-registering. If your username doesn't follow the policy (first name and last name with a space between them) you could be disqualified from the book giveaways.
Thanks,
John
 
Rama moorthy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Fredrik,
Thanks for your coding..It works fine in a stand alone environment.
But can u guide me how to do the same in a real environment.
In my case,i am getting input from the customer in html page.
Once i submit the form it will call the jsp page residing in server.Before it goes to server the user inputs to be encrypted and then sent.
Kindly clarify and advise me how to proceed further.

Kind regards,
N.Rama moorthy
Originally posted by Fredrik Safstrom:
[B]Rama,
Here is the class itself:

It's quite simple to use, here is one example;

You can supply the constructor with a code-key if you want, otherwise the codekey will default to 'Q'.
If you want to add upp characters that are specific for your language in the alphabeth string, my version have some Swedish characters in there. The class will only encrypt/decrypt characters in the alphabeth string, if a character cannot be found, it will be ignored and left as is...
Have fun.
/Bamse[/B]

 
Fredrik Safstrom
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rama,
I haven't used this code in JSP, I guess you can use it in a bean that your JSP page calls.
Here is a "Live" example from an application that store the user and password in an Object called nos.

Later in the program I use the following to encrypt/decrypt the password from a password field.
To Encrypt:

And to Decrypt:

I then serialize the nos Object into a file to save my options to my hard drive.
Hope this helps, I'm sorry to say that I cannot help you with JSP.
/Bamse
 
Sarada Bhasker
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fredrik,
Your encryption code is fantastic. I am breaking my head to find out what logic you have used for encryption. I found one thing in the process, it doesn't take tab character. i was thinking of using it for storing complete client info. Is there any way you can incorporate that as well.
Thanks
Sarada
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic