Re: Encryption Code Problem
Re: Encryption Code Problem
- Subject: Re: Encryption Code Problem
- From: email@hidden
- Date: Thu, 5 Jun 2003 14:58:44 +0100
Jonathan-
On Wednesday, June 4, 2003, at 09:57 pm, Jonathan Fleming wrote:
This is what I'm doing for Denis's code
I draged the try block off of the Sun code example site (
http://javaalmanac.com/egs/java.net/FormEncode.html?|=find ) but I
don't fully understand how to use it. I tried configuring it but to no
avail so i've left it as is hoping someone can help me out.
public void setPassword(String password) {
String encryptedPassword = encrypt(password);
try {
// Construct a x-www-form-urlencoded string
String line = URLEncoder.encode("name1", "UTF-8") + "=" +
URLEncoder.encode("value1", "UTF-8");
line += "&" + URLEncoder.encode("name2", "UTF-8") + "=" +
URLEncoder.encode("value2", "UTF-8");
// Parse a x-www-form-urlencoded string
String[] pairs = line.split("\\&");
for (int i=0; i<pairs.length; i++) {
String[] fields = pairs[i].split("=");
String name = URLDecoder.decode(fields[0], "UTF-8");
String value = URLDecoder.decode(fields[1], "UTF-8");
}
} catch (UnsupportedEncodingException e) {
}
takeStoredValueForKey(encryptedPassword, "password");
}
Forget that.
I wanted to suggest using URLEncoder just as you would use HexCoder,
i.e.
public void setPassword(String password) {
String encryptedPassword = encrypt(password);
String encoded = URLEncoder.encode(encryptedPassword);
//boolean deleteClientDirContents = deleteDir(new
File(sClientDtaDirectory()));
takeStoredValueForKey(encoded, "password");
}
Cheers,
-- Denis.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.