PHP escapeshellarg() 不起作用

PHP escapeshellarg() doesn't work

第一个 shell_exec() 我加密一条消息,第二个 shell_exec() 我想解密我的密码。加密和解密功能运行良好。好像第一个shell_exec() returns一个数据类型不能在第二个shell_exec()中用作变量。我能做什么?

<?php
 $plaintext = "unpuzzle";
 echo '<p>'.$plaintext.'</p>';
 $criptotext = shell_exec('java DES '. escapeshellarg($plaintext) .' 1');
 echo '<p>Criptotext: ' . $criptotext . '</p>';
 $plaintext = shell_exec('java DES '. escapeshellarg($criptotext) .' 2');
 echo '<p>Plaintext: ' . $plaintext . '</p>';
?>

shell_exec returns 命令的输出,最后包含换行符。在将其用作密码文本之前,您需要删除换行符。

$criptotext = rtrim(shell_exec('java DES ' . escapeshellarg($plaintext) . ' 1'), "\r\n");