开发者

php mcrypt and different servers

i'v got such code

function EnDeCrypt($text, $key, $s = 1){
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_R开发者_JAVA技巧AND);
        switch ($s) {
            case '0':
                return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($text), MCRYPT_MODE_ECB, $iv));
                break;
            case '1':
                return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv));
                break;
            default:
                return FALSE;
                break;
        }
    }

if i call EnDeCrypt in one script, all works, if i try to pass encrypted data to different server in get param-i can't decrypt(get such string ŸTe³qëêyÀÝ)

key equals, result put throw urlencode\urldecode-don't decrypt

try to pass vector mcrypt_create_iv -nothing


To decypher, you need to have the same initialization vector ($iv) that was used to cypher.

Pass it as a parameter to your function and all should be fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜