From e22eca366211bbde2a82acbc4fd0c1ca2b9e35d0 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 9 Jun 2010 15:40:19 -0400 Subject: Use different logic for this function, copied from crypt_acb.php. Ticket #537 --- etc/inc/crypt.inc | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'etc/inc/crypt.inc') diff --git a/etc/inc/crypt.inc b/etc/inc/crypt.inc index e13b8ff..dcc359f 100644 --- a/etc/inc/crypt.inc +++ b/etc/inc/crypt.inc @@ -32,26 +32,17 @@ DISABLE_PHP_LINT_CHECKING */ - function crypt_data(& $data, $pass, $opt) { - - $pspec = "/usr/bin/openssl enc {$opt} -aes-256-cbc -k {$pass}"; - $dspec = array( 0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "e")); - - $fp = proc_open($pspec, $dspec, $pipes); - if (!$fp) - return false; - - fwrite($pipes[0], $data); - fclose($pipes[0]); - - $rslt = stream_get_contents($pipes[1]); - fclose($pipes[1]); - - proc_close($fp); - - return $rslt; + function crypt_data($val, $pass, $opt) { + $file = tempnam("/tmp", "php-encrypt"); + $fd = fopen("$file.dec", "w"); + fwrite($fd, $val); + fclose($fd); + exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in $file.dec -out $file.enc -k {$pass}"); + $result = file_get_contents("$file.enc"); + exec("rm $file"); + exec("rm $file.dec"); + exec("rm $file.enc"); + return $result; } function encrypt_data(& $data, $pass) { -- cgit v1.1