Ashley Coolman
Ashley Coolman

Reputation: 11585

Using as3Crypto to encrypt/decrypt without ampersands

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

Upvotes: 2

Views: 845

Answers (1)

lunixbochs
lunixbochs

Reputation: 22415

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

Upvotes: 2

Related Questions