如何换行?例如:
一号线
2号线
3号线
解码后,看起来像 - > line1 line2 line3
$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;
}
答案 0 :(得分:0)
解决。我用nl2br
echo nl2br(htmlspecialchars(mcrypt_decrypt($algo, $key, $ciphertext_dec, $mode, $iv_dec)));