2

I was using as3Crypto with no probs http://www.zedia.net/2009/as3crypto-and-php-what-a-fun-ride/

but then I saw some special characters and I realised I could encounter ampersands. Which is a pain because they will be inserted into a query string. Is there a way to ensure the as3Crypto encryption does not produce ampersands?

public function encrypt(txt:String = ''):String
{
    var data:ByteArray = Hex.toArray(Hex.fromString(txt));      
    var pad:IPad = new PKCS5;
    var mode:ICipher = Crypto.getCipher(type, key, pad);
    pad.setBlockSize(mode.getBlockSize());
    mode.encrypt(data);
    return ''+Base64.encodeByteArray(data);
}
Ashley Coolman
  • 11,095
  • 5
  • 59
  • 81

1 Answers1

2

Assuming a standard base64 implementation, Base64.encodeByteArray(data); will not produce ampersands.

lunixbochs
  • 21,757
  • 2
  • 39
  • 47