2014-06-06 3 views
0

Comment faire un saut de ligne? Par exemple:
line1
line2
line3
après décodage, ressembler -> ligne1 ligne2 ligne3php mcrypt_decrypt, base64_decode et saut de ligne

$key = $_POST['key']; $input = $_POST['text']; 

$algo = MCRYPT_RIJNDAEL_256; 
$mode = MCRYPT_MODE_CBC; 

$iv_size = mcrypt_get_iv_size($algo, $mode); 
$iv = mcrypt_create_iv($iv_size, MCRYPT_DEV_URANDOM); 

switch($_POST['do']){ 
    default: die; 

    case 'encode': 
    $ciphertext = mcrypt_encrypt($algo, $key, $input, $mode, $iv); 
    $ciphertext = $iv . $ciphertext; 
    echo base64_encode($ciphertext); 
    break; 

    case 'decode': 
    $ciphertext_dec = base64_decode($input); 
    $iv_dec = substr($ciphertext_dec, 0, $iv_size); 
    $ciphertext_dec = substr($ciphertext_dec, $iv_size); 
    echo htmlspecialchars(mcrypt_decrypt($algo, $key, $ciphertext_dec, $mode, $iv_dec)); 
    break; 
} 

Répondre

0

Résolu. J'utilise nl2br

echo nl2br(htmlspecialchars(mcrypt_decrypt($algo, $key, $ciphertext_dec, $mode, $iv_dec))); 
Questions connexes