コード例 #1
1
<?php

$plaintext_body = 'Some sensitive order data';
$recipient = '*****@*****.**';
$g = gnupg_init();
gnupg_seterrormode($g, GNUPG_ERROR_WARNING);
// Fingerprint of the recipient's key
$a = gnupg_addencryptkey($g, "5495F0CA9C8F30A9274C2259D7EBE8584CEF302B");
// Fingerprint of the sender's key
$b = gnupg_addsignkey($g, "520D5FC5C85EF4F4F9D94E1C1AF1F7C5916FC221", "passphrase");
$encrypted_body = gnupg_encryptsign($g, $plaintext_body);
mail($recipient, 'Web Site Order', $encrypted_body);
コード例 #2
0
ファイル: class.pgp.php プロジェクト: baki250/angular-io-app
 function encryptString($pubkey, $str)
 {
     putenv("GNUPGHOME=/var/www/.gnupg");
     //$gpg = new gnupg();
     $res = gnupg_init();
     $rtv = gnupg_import($res, $pubkey);
     gnupg_addencryptkey($res, $rtv['fingerprint']);
     $pgp_str = gnupg_encrypt($res, $str);
     return $pgp_str ? $pgp_str : $str;
 }
コード例 #3
0
     ($hook = get_hook('li_login_pre_redirect')) ? eval($hook) : null;
     //redirect(forum_htmlencode($_POST['redirect_url']).((substr_count($_POST['redirect_url'], '?') == 1) ? '&amp;' : '?').'login=1', $lang_login['Login redirect']);
     redirect(FORUM_ROOT . "search.php?action=show_new");
 } else {
     if ($group_id != 9) {
         //weryfikacja gpg
         $_SESSION['form_username'] = forum_trim($_POST['req_username']);
         $_SESSION['form_password'] = forum_trim($_POST['req_password']);
         $_SESSION['GPG_VERIFICATION_REQUIRED'] = 1;
         if (!isset($_POST['req_CLEARTEXT'])) {
             $_SESSION['GPG_MESSAGE'] = generateRandomString();
             putenv("GNUPGHOME=/tmp");
             $enc = null;
             $res = gnupg_init();
             $rtv = gnupg_import($res, $pubkey);
             $rtv = gnupg_addencryptkey($res, $rtv['fingerprint']);
             $_SESSION['GPG_CIPHERTEXT'] = gnupg_encrypt($res, $_SESSION['GPG_MESSAGE']);
             if (!$_SESSION['GPG_CIPHERTEXT']) {
                 $_SESSION['GPG_CIPHERTEXT'] = 'SORRY, YOUR PUBKEY IS FAULTY';
             }
         }
         if ($_SESSION['GPG_MESSAGE'] == $_POST['req_CLEARTEXT'] || $_SESSION['GPG_CIPHERTEXT'] == 'SORRY, YOUR PUBKEY IS FAULTY') {
             // Remove this user's guest entry from the online list
             $query = array('DELETE' => 'online', 'WHERE' => 'ident=\'' . $forum_db->escape(get_remote_address()) . '\'');
             ($hook = get_hook('li_login_qr_delete_online_user')) ? eval($hook) : null;
             $forum_db->query_build($query) or error(__FILE__, __LINE__);
             $expire = $save_pass ? time() + 1209600 : time() + $forum_config['o_timeout_visit'];
             forum_setcookie($cookie_name, base64_encode($user_id . '|' . $form_password_hash . '|' . $expire . '|' . sha1($salt . $form_password_hash . forum_hash($expire, $salt))), $expire);
             ($hook = get_hook('li_login_pre_redirect')) ? eval($hook) : null;
             $_SESSION = array();
             $_SESSION['NOT_BOT'] = 1;
コード例 #4
0
ファイル: GWF_Mail.php プロジェクト: sinfocol/gwf3
 private function encrypt($message)
 {
     if ($this->gpgKey === '' && self::GPG_FINGERPRINT === '') {
         return $message;
     }
     if (false === function_exists('gnupg_init')) {
         return $message . PHP_EOL . 'GnuPG Error: gnupg extension is missing.';
     }
     if (false === ($gpg = gnupg_init())) {
         return $message . PHP_EOL . 'GnuPG Error: gnupg_init() failed.';
     }
     if ($this->gpgKey !== '') {
         if (false === gnupg_addencryptkey($gpg, $this->gpgKey)) {
             return $message . PHP_EOL . 'GnuPG Error: gnupg_addencryptkey() failed.';
         }
     }
     $signed = false;
     //		if (self::GPG_FINGERPRINT !== '') {
     //			$sign_key = preg_replace('/[^a-z0-9]/i', '', self::GPG_FINGERPRINT);
     //
     //			if (self::GPG_PASSPHRASE==='')
     //			{
     //				if (false === gnupg_addsignkey($gpg, $sign_key)) {
     //					$message .= PHP_EOL.'GnuPG Error: gnupg_addsignkey1() failed.';
     //				}
     //				else {
     //					$signed = true;
     //				}
     //			}
     //			else
     //			{
     //				if (false === gnupg_addsignkey($gpg, $sign_key, self::GPG_PASSPHRASE)) {
     //					$message .= PHP_EOL.'GnuPG Error: gnupg_addsignkey2() failed.';
     //				}
     //				else {
     //					$signed = true;
     //				}
     //			}
     //
     //		}
     if ($signed === true) {
         if (false === ($back = gnupg_encryptsign($gpg, $message))) {
             return $message . PHP_EOL . 'GnuPG Error: gnupg_encryptsign() failed.';
         }
     } else {
         if (false === ($back = gnupg_encrypt($gpg, $message))) {
             return 'GnuPG Error: gnupg_encrypt() failed.' . PHP_EOL . 'Message has been removed!';
         }
     }
     return $back;
 }
コード例 #5
0
ファイル: Gpg.php プロジェクト: marketcoinfork/BitWasp-Fork
 /**
  * Encrypt
  *
  * Takes the supplied $fingerprint so GnuPG can load the key from the
  * keyring.
  *
  * @param        string $fingerprint
  * @param        string $plaintext
  * @return        string
  */
 public function encrypt($fingerprint, $plaintext)
 {
     if ($this->style == 'oop') {
         if ($this->gpg->addencryptkey($fingerprint) == FALSE) {
             return FALSE;
         }
         $ciphertext = $this->gpg->encrypt($this->gpg, "{$plaintext}\n");
     } else {
         if ($this->style == 'proc') {
             if (gnupg_addencryptkey($this->gpg, $fingerprint) == FALSE) {
                 return FALSE;
             }
             $ciphertext = gnupg_encrypt($this->gpg, "{$plaintext}\n");
         }
     }
     $full_crypt = "-----BEGIN PGP MESSAGE-----\n" . substr($ciphertext, 28);
     return $full_crypt;
 }
コード例 #6
0
ファイル: Reports.php プロジェクト: Alex--Jin/gt_dashboard
 private function getDORSubmission($CompanyInfo, $ProceedsInfo, $CharitiesInfo)
 {
     $fullxml = "";
     $XmlBody = "";
     $XmlCompanyInfo = "";
     $XmlProcedesBody = "";
     $XmlCharitiesBody = "";
     $XmlMiscInfo = "";
     $XmlBodyClose = "";
     //---------Header Info-------------
     $XmlBody += "<?xml version='1.0' encoding='UTF-8'?>";
     $XmlBody += "<SGOC_Report xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='SGOC_Report.xsd'>";
     $XmlBody += "<Reports>";
     //---------Company Info------------
     $XmlCompanyInfo += "<OrgDetailSec1>";
     $XmlCompanyInfo += "<RptYear>" + $CompanyInfo[0] . rptYear + "</RptYear>";
     $XmlCompanyInfo += "<LicenseNo>" + $CompanyInfo[0] . LicenseNo + "</LicenseNo>";
     $XmlCompanyInfo += "<OrgName>" + $CompanyInfo[0] . CompanyName + "</OrgName>";
     $XmlCompanyInfo += "<CountyCode>" + $CompanyInfo[0] . CountyCode + "</CountyCode>";
     $XmlCompanyInfo += "<MunCode>" + $CompanyInfo[0] . MunCode + "</MunCode>";
     $XmlCompanyInfo += "<AddressLine1>" + $CompanyInfo[0] . CompanyAddress1 + "</AddressLine1>";
     $XmlCompanyInfo += "<City>" + $CompanyInfo[0] . CompanyCity + "</City>";
     $XmlCompanyInfo += "<Zip>" + $CompanyInfo[0] . CompanyZip + "</Zip>";
     $XmlCompanyInfo += "<ContactPhone>" + $CompanyInfo[0] . CompanyPhone + "</ContactPhone>";
     $XmlCompanyInfo += "<ContactName>" + $CompanyInfo[0] . ContactName + "</ContactName>";
     $XmlCompanyInfo += "<LicenseExpDate>" + FormatDateSTD($CompanyInfo[0] . LicenseExpDate) + "</LicenseExpDate>";
     $XmlCompanyInfo += "<LidNo>" + $CompanyInfo[0] . LidNo + "</LidNo>";
     $XmlCompanyInfo += "<FeinSsn>" + $CompanyInfo[0] . FeinSsn + "</FeinSsn>";
     $XmlCompanyInfo += "<IdentityType>" + $CompanyInfo[0] . IdentityType + "</IdentityType>";
     $XmlCompanyInfo += "<FilerName>" + $CompanyInfo[0] . FilerName + "</FilerName>";
     $XmlCompanyInfo += "<FilerTitle>" + $CompanyInfo[0] . FilerTitle + "</FilerTitle>";
     $XmlCompanyInfo += "<FilerPhone>" + $CompanyInfo[0] . FilerPhone + "</FilerPhone>";
     ${$XmlCompanyInfo} += "<NoW2GForms>" + $CompanyInfo[0] . NoW2GForms + "</NoW2GForms>";
     $XmlCompanyInfo += "<TotW2GPrizeAmt>" + $CompanyInfo[0] . TotW2GPrizeAmt + "</TotW2GPrizeAmt>";
     $XmlCompanyInfo += "</OrgDetailSec1>";
     //---------Proceeds----------------
     $i = 0;
     /* for illustrative purposes only */
     foreach ($ProceedsInfo as $ProceedsFeed) {
         //echo "\$a[$i] => $v.\n";
         $XmlProcedesBody += "<ProceedsReportingSec2>";
         $XmlProcedesBody += "<WkBeginDate>" + FormatDateSTD($ProceedsFeed[$i] . wkBegin) + "</WkBeginDate>";
         $XmlProcedesBody += "<WkEndDate>" + FormatDateSTD($ProceedsFeed[$i] . wkEnd) + "</WkEndDate>";
         $XmlProcedesBody += "<GameCode>" + $ProceedsFeed[$i] . GameCode + "</GameCode>";
         $XmlProcedesBody += "<GrossRevenue>" + $ProceedsFeed[$i] . Gross + "</GrossRevenue>";
         $XmlProcedesBody += "<TotalExpenses>" + $ProceedsFeed[$i] . Expenses + "</TotalExpenses>";
         $XmlProcedesBody += "<TotalPrizes>" + $ProceedsFeed[$i] . Prizes + "</TotalPrizes>";
         $XmlProcedesBody += "<Proceeds>" + $ProceedsFeed[$i] . Proceeds + "</Proceeds>";
         $XmlProcedesBody += "</ProceedsReportingSec2>";
         $i++;
     }
     //---------Charities---------------
     $i = 0;
     /* for illustrative purposes only */
     foreach ($CharitiesInfo as $CharitiesFeed) {
         //echo "\$a[$i] => $v.\n";
         $XmlCharitiesBody += "<AmtProceedsPublicIntSec3>";
         $XmlCharitiesBody += "<DateDistributed>" + FormatDateSTD($CharitiesFeed[$i] . DatePaid) + "</DateDistributed>";
         $XmlCharitiesBody += "<RecipientName>" + $CharitiesFeed[$i] . Charity + "</RecipientName>";
         $XmlCharitiesBody += "<AmtSetaSide>" + $CharitiesFeed[$i] . AmtPaid + "</AmtSetaSide>";
         $XmlCharitiesBody += "</AmtProceedsPublicIntSec3>";
         $i++;
     }
     //---------Misc Items--------------
     $XmlMiscInfo += "<ProceedsExpAndAmtSetaSideSec4>";
     $XmlMiscInfo += "<TotProceedsOperExp>206.38</TotProceedsOperExp>";
     $XmlMiscInfo += "<TotAmtSetaSide>111.11</TotAmtSetaSide>";
     $XmlMiscInfo += "</ProceedsExpAndAmtSetaSideSec4>";
     $XmlMiscInfo += "<Miscellaneous>";
     $XmlMiscInfo += "<PrYrProceeds>" + "Y" + "</PrYrProceeds>";
     $XmlMiscInfo += "</Miscellaneous>";
     //---------Close XML---------------
     $XmlBodyClose += "</Reports>";
     $XmlBodyClose += "</SGOC_Report>";
     $fullxml = $XmlBody + $XmlCompanyInfo + $XmlProcedesBody + $XmlCharitiesBody + $XmlMiscInfo + $XmlBodyClose;
     //---------Encrypt String----------
     $stringToEncrypt = $fullxml;
     $res = gnupg_init();
     $pubkey = "BADelitpUqMZLn+bryZR5rK9J3eu+pRVFP5tpboOlIwO2vqO/rCi8VvT2TPzEJarWhyZ465NIohYCiia9vaGUEp4rsDzFnVNgpON47yPew1zCmOOofituf+X6Qlaxylm5NnO4vnRcmoF4IbGwSCqyGgGor29D75Hovwlj1q6BWHYWwAGKQ==";
     //gnupg_addencryptkey($res,"8660281B6051D071D94B5B230549F9DC851566DC");
     gnupg_addencryptkey($res, $pubkey);
     $enc = gnupg_encrypt($res, $stringToEncrypt);
     return $enc;
 }