开发者

Rijndael PHP encode FLASH decode

开发者 https://www.devze.com 2023-03-15 02:18 出处:网络
I am trying to pass some encrypted data to a flash , but I got stuck somewhere in the middle. Im using RIJNDAEL algorithm to encode the dat开发者_JS百科a in PHP :

I am trying to pass some encrypted data to a flash , but I got stuck somewhere in the middle.

Im using RIJNDAEL algorithm to encode the dat开发者_JS百科a in PHP :

function encrypt($text){
    $key = "53cded30ff7ba54d65b939fd594e3d63";
    $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC); //get vector size on CBC mode 
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); //Creating the vector
    $cryptedtext = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_CBC, $iv); //Encrypting using MCRYPT_RIJNDAEL_256 algorithm 
    return $cryptedtext;
}

And im using the AS3CRYPT library to decrypt the value in flash.

The problem is that if I try to decode the value in flash or even in the demo of AS3CRYPT, it doesnt work.

I also tried to return the data from PHP encoded with base64_encode but still not working.

The output from PHP is something like : flashvar=Á žJcV—µg)7¾1´‘5{Ò<¶Ù$þS„§”

Probably I did something wrong in the PHP ...


PHP doesn't add any padding, which is likely needed.

You'll have to pad it manually, take a look at this post on PHP.net which explains one method of achieving PKCS7 padding compatibility.

Beyond that, make sure you're setting the matching confidentiality mode (CBC) and cipher within "AS3CRYPTO".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号