Question

I am trying to encrypt a string using a command created in C in my remote server where my database is located. But shell_exec keeps giving me a call to undefined function error. What are the steps to make this function defined? Am I using this function correct?

function encrypt($string) {
    $output = shell_exec('');
    echo "<pre>$output</pre>"; 
}

$string = "some_string"; 
$encryptedString = encrypt($string); 
Was it helpful?

Solution

You need to blacklist the shell_exec from the safe mode.

Sidenote : If it works, you need to escape the $string using the escapeshellarg() before passing it to your shell_exec() function.

Like this..

function encryptTFS($string) {
    $output = shell_exec('tea32 -e -"'.escapeshellarg($string).'" -ofilenameoutout');
    echo "<pre>$output</pre>"; 
}

$string = "some_string"; 
$encryptedString = encryptTFS($string); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top