Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Encrypt string and store in cookie

843811Sep 10 2007 — edited Sep 11 2007
Hi,

I want to implement a "remember me" feature for my website. The requiement is to be able to login user automatically if the right cookie is set. Here's what I planning to do: encrypt the username using a passphrase (my own password) and store the encrypted username in cookie, set certain life span for the cookie. On the login side, get encrypted data from cookie, decrypt it using the same passphrase and get the username.

I need a simple way to encrypt string (user username) and store it in cookie. Found this thread:
http://forum.java.sun.com/thread.jspa?threadID=572913&messageID=2842005

This is kind of old. Not sure if still valid.

Need to implement one util with methods of
String encrpt(String data, String passphrase)
String decrpt(String encryptedData, String passphrase)

Also, do I need to use Base64Encoder to turn byte array to cookie storable string?

thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 9 2007
Added on Sep 10 2007
2 comments
220 views