Ashley Coolman
Ashley Coolman

Reputation: 11575

Using as3Crypto to encrypt/decrypt with only URL Query save chars

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

but it produces a string which includes equal (and probably other URL Query unsafe characters). Is there a way to encrypt like this?

Current code below:

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: 0

Views: 1720

Answers (1)

Maarten Bodewes
Maarten Bodewes

Reputation: 93948

Yes, base 64 encoding is the normal way to do this, although you must still URL escape the result, because Base64 contains unsafe characters as well ('/', '+' and '=' to be precise).

Upvotes: 1

Related Questions