From 3b01505e656b1db5f9baff19620c5867cb77de63 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 8 Oct 2008 17:37:56 +0000 Subject: Revise crypt_data() a bit to avoid hanging --- packages/autoconfigbackup/crypt_acb.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'packages') diff --git a/packages/autoconfigbackup/crypt_acb.php b/packages/autoconfigbackup/crypt_acb.php index 2fa5fc64..22a40ae2 100644 --- a/packages/autoconfigbackup/crypt_acb.php +++ b/packages/autoconfigbackup/crypt_acb.php @@ -29,24 +29,46 @@ DISABLE_PHP_LINT_CHECKING */ - function crypt_data(& $data, $pass, $opt) { + function crypt_data($val, $pass) { + $val = str_replace("'", "#%$", $val); + $file = tempnam('','php-encrypt-'); + exec("echo -E '$val' > $file.dec"); + exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in $file.dec -out $file.enc -k {$pass}"); + $myfile = file("$file.enc"); + exec("rm $file"); + exec("rm $file.dec"); + exec("rm $file.enc"); + while (list($line_num, $line) = each($myfile)) { + $result .= $line; + } + $result = base64_encode($result); + $result = urlencode($result); + return $result; + } + function crypt_dataA(& $data, $pass, $opt) { + log_error("entering crypt_data()"); $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")); - + log_error("proc_open"); $fp = proc_open($pspec, $dspec, $pipes); if (!$fp) return false; - + log_error("writing to pipe[0]"); fwrite($pipes[0], $data); + log_error("closing pipe[0]"); fclose($pipes[0]); - + + log_error("enter while()"); + while (!feof($pipes[1])) { $rslt .= fread($pipes[1], 8192); } - + + log_error("exit while()"); + fclose($pipes[1]); proc_close($fp); -- cgit v1.2.3