|
please loook at the following code where i am encrypting a data.
<?php
$sender_name=$_POST['sender_name'];
$sender_email=$_POST['sender_email'];
$secret_msg=$_POST['secret_msg'];
//build the message string
$msg = "Sender's Full Name:\t$sender_name\n";
$msg .= "Sender's E-Mail:\t$sender_email\n";
$msg .= "Secret Message?\t$secret_msg\n\n";
//generate token for unique filenames
$tmpToken = md5(uniqid(rand()));
//create vars to hold paths and filenames
$plainTxt = "tmp/" . "$tmpToken" . "data";
$crypted = "tmp/" . "$tmpToken" . "pgpdata";
//open file and dump in plaintext contents
$fp = fopen($plainTxt, "w+");
fputs($fp, $msg);
fclose($fp);
//set the environment variable for PGPPATH
putenv("GNUPGHOME=/home/www/.gnupg");
//invoke PGP to encrypt file contents
system("/usr/bin/gpg -r 'subhas_xgen@yahoo.co.in' -o $crypted -a $plainTxt");
//open file and read encrypted contents into var
$fd = fopen($crypted, "r");
$mail_cont = fread($fd, filesize($crypted));
fclose($fd);
//delete files!
//unlink($plainTxt);
//unlink($crypted);
// Build mail message and send it to target recipient.
$recipient = "subhas_xgen@yahoo.co.in";
$subject = "Secret Message";
$mailheaders = "From: My Web Site\n";
$mailheaders .= "Reply-To: $sender_email\n\n";
mail("$recipient", "$subject", $mail_cont, $mailheaders);
// Print confirmation to screen.
echo "
<H1 align=center>Thank You, $sender_name</h1>
<p align=center>Your secret message has been sent.</p>
";
?>
it will take the contents of $plainTxt and write in Encrypted format to another file called $crypted .
But its not going on . Please help me as soon as possible
|