• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Encryption Code Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Encryption Code Problem


  • Subject: Re: Encryption Code Problem
  • From: "Jonathan Fleming" <email@hidden>
  • Date: Wed, 04 Jun 2003 21:57:56 +0100

From: email@hidden
To: Jonathan Fleming <email@hidden>
CC: email@hidden
Subject: Re: Encryption Code Problem
Date: Wed, 4 Jun 2003 14:13:58 +0100


On Tuesday, June 3, 2003, at 08:23 pm, Jonathan Fleming wrote:

I suspect your binary stream is not surviving the roundtrip to the
database. Try Hex-encoding the binary stream first before storing it to
the database, and decoding it upon retrival. That way you're only storing
ASCII characters, which is much more likely to work.


Both Apache Jakarta and BouncyCastle have hex encoder/decoder available.

Or you could simply use java.net.URLEncoder and java.net.URLDecoder.

Hello Jonathan & Denis

In either case I'm stuck I don't know how to get this to work:
My business logic class TbControlPanel is where I am saving the encrypted text to the database so I suspect that I need to do the hex encoding here just before takeStoredValueForKey, trouble is i'm not quite managing it and need your help.
All relevant .jar files / packages have been installed and imported.


This is what I'm doing for Jonathan's code

public void setPassword(String password) {
String encryptedPassword = encrypt(password);
HexCoder hex = hex.encode(encryptedPassword);
//boolean deleteClientDirContents = deleteDir(new File(sClientDtaDirectory()));


       takeStoredValueForKey(hex, "password");
   }

====================================================


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");
   }

====================================================

I imagine run the decoding process when retieving the passwords which I would do here:

   public WOComponent login() {
     NSMutableDictionary lookup = new NSMutableDictionary();

lookup.setObjectForKey(username/*.toLowerCase()*/, "loginName");
lookup.setObjectForKey(TbControlPanel.encrypt(password), "password");
NSLog.out.appendln("===\r login password is set to: " + TbControlPanel.encrypt(password) );



EOEditingContext ec = defaultEditingContext();
NSArray result = EOUtilities.objectsMatchingValues(ec, "TbControlPanel", lookup);
NSLog.out.appendln("===\r login results = " + result );


     if (result.count() == 1) {
       setUser( (TbControlPanel) result.objectAtIndex(0));
     }

     return null;
   }

====================================================


Also, Raphael Szwarc wrote one and posted it:

<http://www.wodeveloper.com/omniLists/webobjects-dev/2002/July/ msg00157.htm
l>

Thanks for this Jonathan but that link seems to be dead. Is there an alternative way of obtaining this?
such as an attachment if under 1.8mg else I'll have to send you my private e-mail address


Cheers
Jonathan :^)



_________________________________________________________________
Sign-up for a FREE BT Broadband connection today! http://www.msn.co.uk/specials/btbroadband
_______________________________________________
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.

  • Follow-Ups:
    • Re: Encryption Code Problem
      • From: email@hidden
  • Prev by Date: Re: Your session has timed out.
  • Next by Date: Re: Your session has timed out.
  • Previous by thread: Re: Encryption Code Problem
  • Next by thread: Re: Encryption Code Problem
  • Index(es):
    • Date
    • Thread