发送加密文件(zip或txt)-通过PHP-可在Windows PC上打开

发送加密文件(zip或txt)-通过PHP-可在Windows PC上打开,php,encryption,zip,Php,Encryption,Zip,我需要通过电子邮件向用户发送一些最低限度的数据(但必须加密) 他们需要对附件进行DL加密,并使用某种易于使用的软件(PC/MAC)对其进行解密。。。有什么想法吗 我的第一个想法是制作一个加密的zip文件,他们可以用7zip或winzip打开。。。但我发现,这在典型的PHP/Linux应用程序中是不可能发生的。不是一个解决方案,您可以在服务器上存储存档,然后通过电子邮件链接发送到PHP页面,该页面可以获取特定的zip,并在用户使用基本身份验证登录后将其发送给用户。因此,只有知道密码的用户才能执行该

我需要通过电子邮件向用户发送一些最低限度的数据(但必须加密)

他们需要对附件进行DL加密,并使用某种易于使用的软件(PC/MAC)对其进行解密。。。有什么想法吗


我的第一个想法是制作一个加密的zip文件,他们可以用7zip或winzip打开。。。但我发现,这在典型的PHP/Linux应用程序中是不可能发生的。

不是一个解决方案,您可以在服务器上存储存档,然后通过电子邮件链接发送到PHP页面,该页面可以获取特定的zip,并在用户使用基本身份验证登录后将其发送给用户。因此,只有知道密码的用户才能执行该脚本并下载文件。
您认为呢?

不是一个解决方案,您可以将档案存储在服务器上,然后通过电子邮件链接发送到php页面,该页面可以获取特定的zip,并在用户使用基本身份验证登录后将其发送给用户。因此,只有知道密码的用户才能执行该脚本并下载文件。
你觉得怎么样?

典型的PHP应用程序不会发生什么?您当然可以压缩文件:

典型的PHP应用程序不会发生什么?您当然可以压缩文件:

您可以使用和来加密消息。你可以找到许多为河豚加密/解密的程序,例如


测试:

string(96)“dþgþJ\V$3Äö,[yþ和“¼þþþþþþþþþ207;=$dG|bþþþþIþþþþ8þTé5您可以使用和加密消息。您可以找到许多用于河豚鱼的加密/解密程序,例如


测试:

string(96)“dþgþJ\V$3Äö,[yþ和”¼þþþþþþþþþ207;=$dG|bþþbþþIþI½5我使用GNUPG:

您需要访问您的Web服务器才能安装它,或者如果已安装,则需要添加密钥环

然后,您可以将它与exec调用或gnupgpecl扩展一起使用

问题是,用户必须使用与您加密相同的电子邮件地址($gpgrecient)创建密钥,他们必须在您加密密钥之前创建密钥,并将其上载到公钥服务器(软件将执行此操作)。然而,该软件非常简单,而且是跨平台的

对于我的php加密脚本,我使用:

<?php
//error_reporting(E_ALL);
echo 'GNUPG Test<br /><br />';

putenv("GNUPGHOME=/home/me/.gnupg");

$gpg = '/usr/bin/gpg';
$gpgrecipient = 'ben@mydomain.com';
$plaintext = 'This should be encrypted!!!!';



$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin 
   1 => array("pipe", "w"),  // stdout 
   2 => array("file", "/usr/home/me/error-output.txt", "a") // stderr is a file to write to
);

$cwd = '/usr/bin/';
$env = array('GNUPGHOME' => '/usr/home/me/.gnupg');


$process = proc_open("gpg --no-auto-check-trustdb -q --auto-key-locate keyserver --no-secmem-warning --lock-never -e -a -r {$gpgrecipient}", 
                        $descriptorspec, $pipes, $cwd, $env);

if (is_resource($process)) {
    // $pipes now looks like this:
    // 0 => writeable handle connected to child stdin
    // 1 => readable handle connected to child stdout

    fwrite($pipes[0], $plaintext);
    fclose($pipes[0]);

    $encrypted = stream_get_contents($pipes[1]);
    fclose($pipes[1]);

    // It is important that you close any pipes before calling
    // proc_close in order to avoid a deadlock
    $return_value = proc_close($process);

 //   echo "\n\n command returned $return_value\n";

    $message = "

This is what we should have ideally (Encrypted Emails). 
Unencrypted text - name, date of arrival, etc. 
This part only Is encrypted and requires a password to view:

{$encrypted} 

More Unencrypted text at the end";


mail($mailrecp, 'Encrypted Emails Example', $message);

}


?>

这只会加密电子邮件的一部分,我用thunderbird和enigmail检索到它

您可以将其更改为输入文件,并将其附加到电子邮件

你甚至可以找到一个裸体的gnupg应用程序,它可以创建一个密钥并将其上传到公共服务器,解密一个文件,等等

如果数据真的很敏感,我认为GnuPG是一个不错的选择

比如说,处理只需要发送一封由你控制的电子邮件的在线预订要比处理你需要的电子邮件好得多,但我想我会把它扔出去。

我使用GNUPG:

您需要访问您的Web服务器才能安装它,或者如果已安装,则需要添加密钥环

然后,您可以将它与exec调用或gnupgpecl扩展一起使用

问题是,用户必须使用与您加密相同的电子邮件地址($gpgrecient)创建密钥,他们必须在您加密密钥之前创建密钥,并将其上载到公钥服务器(软件将执行此操作)。然而,该软件非常简单,而且是跨平台的

对于我的php加密脚本,我使用:

<?php
//error_reporting(E_ALL);
echo 'GNUPG Test<br /><br />';

putenv("GNUPGHOME=/home/me/.gnupg");

$gpg = '/usr/bin/gpg';
$gpgrecipient = 'ben@mydomain.com';
$plaintext = 'This should be encrypted!!!!';



$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin 
   1 => array("pipe", "w"),  // stdout 
   2 => array("file", "/usr/home/me/error-output.txt", "a") // stderr is a file to write to
);

$cwd = '/usr/bin/';
$env = array('GNUPGHOME' => '/usr/home/me/.gnupg');


$process = proc_open("gpg --no-auto-check-trustdb -q --auto-key-locate keyserver --no-secmem-warning --lock-never -e -a -r {$gpgrecipient}", 
                        $descriptorspec, $pipes, $cwd, $env);

if (is_resource($process)) {
    // $pipes now looks like this:
    // 0 => writeable handle connected to child stdin
    // 1 => readable handle connected to child stdout

    fwrite($pipes[0], $plaintext);
    fclose($pipes[0]);

    $encrypted = stream_get_contents($pipes[1]);
    fclose($pipes[1]);

    // It is important that you close any pipes before calling
    // proc_close in order to avoid a deadlock
    $return_value = proc_close($process);

 //   echo "\n\n command returned $return_value\n";

    $message = "

This is what we should have ideally (Encrypted Emails). 
Unencrypted text - name, date of arrival, etc. 
This part only Is encrypted and requires a password to view:

{$encrypted} 

More Unencrypted text at the end";


mail($mailrecp, 'Encrypted Emails Example', $message);

}


?>

这只会加密电子邮件的一部分,我用thunderbird和enigmail检索到它

您可以将其更改为输入文件,并将其附加到电子邮件

你甚至可以找到一个裸体的gnupg应用程序,它可以创建一个密钥并将其上传到公共服务器,解密一个文件,等等

如果数据真的很敏感,我认为GnuPG是一个不错的选择


比如说,处理只需要发送一封电子邮件就可以控制的在线预订比处理您需要的要好得多,但我想我会把它扔出去。

您知道他们必须知道密码,对吗?定义最小值。@webarto minimal,与所有文本一样,不到1000字。您知道他们必须知道密码,对吗?定义最小值。@webarto-minimal,与所有文本一样,少于1000字。对不起,应该指定,我也不想将文件存储在服务器上…对不起,应该指定,我也不想将文件存储在服务器上…我想我最喜欢…将尝试一下。我想我最喜欢…将尝试一下。是的但是所有其他方法都要求他们知道密码。这是我知道的唯一一种他们可以在哪里创建自己的密码的方法。是的……但是所有其他方法都要求他们知道密码。这是我知道的唯一一种他们可以在哪里创建自己的密码的方法。
<?php
//error_reporting(E_ALL);
echo 'GNUPG Test<br /><br />';

putenv("GNUPGHOME=/home/me/.gnupg");

$gpg = '/usr/bin/gpg';
$gpgrecipient = 'ben@mydomain.com';
$plaintext = 'This should be encrypted!!!!';



$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin 
   1 => array("pipe", "w"),  // stdout 
   2 => array("file", "/usr/home/me/error-output.txt", "a") // stderr is a file to write to
);

$cwd = '/usr/bin/';
$env = array('GNUPGHOME' => '/usr/home/me/.gnupg');


$process = proc_open("gpg --no-auto-check-trustdb -q --auto-key-locate keyserver --no-secmem-warning --lock-never -e -a -r {$gpgrecipient}", 
                        $descriptorspec, $pipes, $cwd, $env);

if (is_resource($process)) {
    // $pipes now looks like this:
    // 0 => writeable handle connected to child stdin
    // 1 => readable handle connected to child stdout

    fwrite($pipes[0], $plaintext);
    fclose($pipes[0]);

    $encrypted = stream_get_contents($pipes[1]);
    fclose($pipes[1]);

    // It is important that you close any pipes before calling
    // proc_close in order to avoid a deadlock
    $return_value = proc_close($process);

 //   echo "\n\n command returned $return_value\n";

    $message = "

This is what we should have ideally (Encrypted Emails). 
Unencrypted text - name, date of arrival, etc. 
This part only Is encrypted and requires a password to view:

{$encrypted} 

More Unencrypted text at the end";


mail($mailrecp, 'Encrypted Emails Example', $message);

}


?>