Encrypt string and store in cookie
843811Sep 10 2007 — edited Sep 11 2007Hi,
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!