예제 #1
0
//Set the subject line
$mail->Subject = 'RE: PHPMailer sendmail test';
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//send the message, check for errors
if (!$mail->send()) {
    echo "<br>Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "<br>Message sent!";
}
echo "\n<hr>STR:<hr>\n'{$raw}'\n<hr>\n{$method}\n<hr>\n{$pass}\n<hr>\nENC: {$enc}\n<hr>\nDEC: '{$dec}'\n";
if (0) {
    $str1 = enc_str('mark-tejero');
    $str2 = dec_str($str1);
    echo "\n{$str1}\n<hr>\n{$str2}\n<hr>\n";
    function enc_str($str, $key = '1234567890!')
    {
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM);
        $encrypted = base64_encode($iv . mcrypt_encrypt(MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), $str, MCRYPT_MODE_CBC, $iv));
        echo "ENCRYPT> {$str} -> \${$encrypted}\n";
        return $encrypted;
    }
    function dec_str($str, $key = '1234567890!')
    {
        $data = base64_decode($str);
        $iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
        $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, hash('sha256', $key, true), substr($data, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)), MCRYPT_MODE_CBC, $iv), "");
        echo "DECRYPT> {$str} -> \${$decrypted}\n";
        return $decrypted;
예제 #2
0
function dec_file($file, $key)
{
    $fp_r = fopen("{$file}", "rb");
    $fp_w = fopen("dec_{$file}", "wb");
    if (!$fp_r || !$fp_w) {
        die("Cannot Read or Write File !");
    }
    $enc_key = md5($key);
    if ($enc_key != fread($fp_r, strlen($enc_key))) {
        fclose($fp_r);
        fclose($fp_w);
        unlink("dec_{$file}");
        die("Wrong Decryption Key !");
    }
    while (!feof($fp_r)) {
        $data = fread($fp_r, 1024);
        $dec_text = dec_str($data, $key);
        fwrite($fp_w, $dec_text);
    }
    fclose($fp_r);
    fclose($fp_w);
    unlink($file);
    rename("dec_{$file}", $file);
    return;
}