1 Reply Latest reply on Dec 3, 2007 11:34 AM by eyewell

    Base 64 Encode/Decode

      I consider sending clear text problematic when the data ends up as XML information. Converting the text Strings to Base 64 between PHP and Flex 2 (or anything else and Flex 2) eliminates issues with character text like <> and &'s. I've done a lot of XMLRPC coding and always sent text data values that are Base 64 format. The built in Flex 2 Base 64 functions make this easier. On the PHP side, you can use

      $b64StringVal = base64_encode ( $stringData );
      $stringData = base64_decode ( $b64StringVal );

      to convert.

      If you are using Java at th back end, look at:

      Definitions in the CDATA area:

      import mx.utils.Base64Encoder;
      import mx.utils.Base64Decoder;
      import flash.utils.ByteArray;

      public function encodeB64(target:String) : String
      var be:Base64Encoder = new Base64Encoder();
      var encodedData:String = be.flush();
      return encodedData;
      public function decodeB64(target:String) : String
      var bd:Base64Decoder = new Base64Decoder();
      var decodedData:ByteArray = bd.drain();
      return decodedData.toString();

      [Bindable] public var myData:String = new String();

      private function loginResult(evt:ResultEvent):void {
      var b64MyData:String = evt.result.MyData;

      In the mxml area:

      <mx:HTTPService id="loginPage" url=" http://localhost/xxx.php" useProxy="false" method="POST" />
      <mx:Model id="loginModel1">