Does my decryption colde look right?

Discussion in 'PHP' started by bigmike7801, Dec 22, 2009.

  1. #1
    This seems to work fine in IE8, but whenever I view it in FF3, There is some weird trailing characters after the decrypted text.

    
    $decryption_key = "Yru8S09edICE";
    $cipher_alg=MCRYPT_RIJNDAEL_256;
    
    function hex2bin($data) {
        $len = strlen($data);
        return pack("H" . $len, $data);
    } 
    
    $iv = bin2hex(mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg, MCRYPT_MODE_CBC), MCRYPT_RAND));
    
    $encryppted_text = mcrypt_encrypt($cipher_alg, $decryption_key, 'this is text', MCRYPT_MODE_CBC, hex2bin($iv));
    
    print $encryppted_text."<br />";
    
    $decrypted_text = mcrypt_decrypt($cipher_alg, $decryption_key, $encryppted_text, MCRYPT_MODE_CBC, hex2bin($iv));
    
    print $decrypted_text;
    
    PHP:
     
    Last edited: Dec 22, 2009
    bigmike7801, Dec 22, 2009 IP
  2. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sounds like you need to set the charset in the content type meta tag
     
    JAY6390, Dec 22, 2009 IP