Example #1
0
		You can statically specify a "default" cipher, mode, base64 flag and key by modifying
		the appropriate static member variable on the class, or you can specify these fields
		explicitly when constructing a new instance of <b>QCryptography</b>.<br/><br/>
		
		<b>QCryptography</b> also supports the encryption and decryption of entire files.<br/><br/>

		For more information about the <b>libmcrypt</b> library, please refer to the
		<a href="http://www.php.net/manual/en/ref.mcrypt.php" class="bodyLink">PHP Documentation</a>.<br/><br/>
	</div>

	<h3>TripleDES, Electronic Codebook Encryption</h3>
<?php 
$strOriginal = 'The quick brown fox jumps over the lazy dog.';
// Modify the cipher and base64 mode by modifying the "default" cipher and mode on the class, itself
// Specify a Key (this would typically be defined as a constant (e.g. in _configuration.inc)
QCryptography::$Key = 'SampleKey';
// By default, let's leave Base64 encoding turned off
QCryptography::$Base64 = false;
$objCrypto = new QCryptography();
$strEncrypted = $objCrypto->Encrypt($strOriginal);
$strDecrypted = $objCrypto->Decrypt($strEncrypted);
printf('Original Data: <b>%s</b><br/>', $strOriginal);
printf('Encrypted Data: <b>%s</b><br/>', $strEncrypted);
printf('Decrypted Data: <b>%s</b><br/><br/><br/>', $strDecrypted);
?>



	<h3>TripleDES, Electronic Codebook Encryption (with Base64 encoding)</h3>
<?php 
$strOriginal = 'Just keep examining every low bid quoted for zinc etchings.';
Example #2
0
 public function btnAdd_Click()
 {
     //Save or create all necessary objects
     // Create RecurringDonation
     if (!$this->isEdit) {
         $this->objRecurringDonation = new RecurringDonation();
         $this->objRecurringDonation->PersonId = QApplication::$PublicLogin->Person->Id;
         $this->objRecurringDonation->ConfirmationEmail = QApplication::$PublicLogin->Person->PrimaryEmail->Address;
     }
     $this->objRecurringDonation->Amount = $this->GetAmount();
     $this->objRecurringDonation->Save();
     //Create RecurringPayment object - and associate with RecurringDonation.
     if (!$this->isEdit) {
         $objRecurringPayment = new RecurringPayments();
     } else {
         $objRecurringPayment = RecurringPayments::Load($this->objRecurringDonation->RecurringPaymentId);
     }
     QCryptography::$Key = CRYPTO_KEY;
     $objCrypto = new QCryptography(null, false);
     $objRecurringPayment->Address1 = $objCrypto->Encrypt(trim($this->pnlPayment->txtAddress1->Text));
     $objRecurringPayment->Address2 = $objCrypto->Encrypt(trim($this->pnlPayment->txtAddress2->Text));
     $objRecurringPayment->City = $objCrypto->Encrypt(trim($this->pnlPayment->txtCity->Text));
     $objRecurringPayment->State = trim($this->pnlPayment->lstState->SelectedValue);
     $objRecurringPayment->Zip = $objCrypto->Encrypt(trim($this->pnlPayment->txtZipCode->Text));
     $objRecurringPayment->ExpirationDate = sprintf('%02d%02d', $this->pnlPayment->lstCcExpMonth->SelectedValue, substr($this->pnlPayment->lstCcExpYear->SelectedValue, 2));
     //$objCrypto->Encrypt(sprintf('%02d%02d', $this->pnlPayment->lstCcExpMonth->SelectedValue, substr($this->pnlPayment->lstCcExpYear->SelectedValue, 2)));
     $objRecurringPayment->SecurityCode = $objCrypto->Encrypt($this->pnlPayment->txtCcCsc->Text);
     $objRecurringPayment->CreditCardTypeId = $this->pnlPayment->lstCcType->SelectedValue;
     $objRecurringPayment->CardHolderName = $objCrypto->Encrypt(sprintf('%s %s', $this->pnlPayment->txtFirstName->Text, $this->pnlPayment->txtLastName->Text));
     $objRecurringPayment->AccountNumber = $objCrypto->Encrypt($this->pnlPayment->txtCcNumber->Text);
     $objRecurringPayment->AuthorizeFlag = $this->chkAgreement->Checked;
     $objRecurringPayment->StartDate = $this->dtxStartDate->DateTime;
     $objRecurringPayment->EndDate = $this->dtxEndDate->DateTime;
     $objRecurringPayment->Amount = $this->GetAmount();
     $objRecurringPayment->PaymentPeriodId = $this->lstPaymentPeriod->SelectedValue;
     $objRecurringPayment->Name = $this->txtPaymentName->Text;
     $intRecurringPaymentId = $objRecurringPayment->Save();
     if (!$this->isEdit) {
         $this->objRecurringDonation->RecurringPaymentId = $intRecurringPaymentId;
         $this->objRecurringDonation->Save();
     }
     // Create RecurringDonationItems - And associate with RecurringDonation
     foreach ($this->objDonationItemArray as $objDonationItem) {
         if ($objDonationItem->Amount) {
             $objOnlineDonationLineItem = clone $objDonationItem;
             $objOnlineDonationLineItem->RecurringDonationId = $this->objRecurringDonation->Id;
             $objOnlineDonationLineItem->DonationFlag = true;
             $objOnlineDonationLineItem->Save();
         }
     }
     QApplication::Redirect('/give/recurring.php');
 }
<?php

QCryptography::$Key = CRYPTO_KEY;
$objCrypto = new QCryptography(null, false);
// iterate through all recurring payments within the time period.
$objRecurringPaymentCursor = RecurringPayments::QueryCursor(QQ::AndCondition(QQ::LessOrEqual(QQN::RecurringPayments()->StartDate, date('Y-m-d')), QQ::GreaterOrEqual(QQN::RecurringPayments()->EndDate, date('Y-m-d'))));
while ($objRecurringPayment = RecurringPayments::InstantiateCursor($objRecurringPaymentCursor)) {
    // display information..
    print sprintf("Payment of: %s within time period: %s - %s\n", $objRecurringPayment->Amount, $objRecurringPayment->StartDate, $objRecurringPayment->EndDate);
    print sprintf("name : %s\nAddress: %s %s\n City: %s\nState: %s\nZip: %s\n", $objCrypto->Decrypt($objRecurringPayment->CardHolderName), $objCrypto->Decrypt($objRecurringPayment->Address1), $objCrypto->Decrypt($objRecurringPayment->Address2), $objCrypto->Decrypt($objRecurringPayment->City), $objRecurringPayment->State, $objCrypto->Decrypt($objRecurringPayment->Zip));
    print sprintf("Account Number: %s\nExpiration Date: %s\nSecurity code: %s\n", $objCrypto->Decrypt($objRecurringPayment->AccountNumber), $objRecurringPayment->ExpirationDate, $objCrypto->Decrypt($objRecurringPayment->SecurityCode));
    print sprintf("CreditCard Type: %d\n", $objRecurringPayment->CreditCardTypeId);
    // identify if any are due today
    $startDate = $objRecurringPayment->StartDate;
    $timePeriod = 0;
    switch ($objRecurringPayment->PaymentPeriod->Id) {
        case 1:
            // weekly
            $timePeriod = 7 * 24 * 60 * 60;
            break;
        case 2:
            // bi-weekly
            $timePeriod = 2 * 7 * 24 * 60 * 60;
            break;
        case 3:
            // monthly
            $timePeriod = 30 * 24 * 60 * 60;
            break;
        case 4:
            // quarterly
            $timePeriod = 4 * 30 * 24 * 60 * 60;
Example #4
0
File: index.php Project: alcf/chms
<?php

require dirname(__FILE__) . '/../../includes/prepend.inc.php';
$strPayload = QApplication::PathInfo(0);
try {
    QCryptography::$Key = file_get_contents(__INCLUDES__ . '/../sso_key.txt');
    $objCrypto = new QCryptography();
    $strPayload = $objCrypto->Decrypt($strPayload);
} catch (Exception $objExc) {
    QApplication::Logout();
    QApplication::Redirect('/');
}
$strTokens = explode("_", $strPayload);
if (count($strTokens) != 2) {
    QApplication::Logout();
    QApplication::Redirect('/');
}
$strUsername = $strTokens[0];
$intTime = $strTokens[1];
if ($intTime < time() - 5 || $intTime > time() + 5) {
    QApplication::Logout();
    QApplication::Redirect('/');
}
$objLogin = Login::LoadByUsername($strUsername);
if (!$objLogin) {
    QApplication::Logout();
    QApplication::Redirect('/');
}
QApplication::Login($objLogin);
QApplication::Redirect('/');
 public function __construct($objParentObject, $strControlId = null, Address $objAddress = null, $strFirstName = null, $strLastName = null, RecurringPayments $objRecurringPayment = null)
 {
     parent::__construct($objParentObject, $strControlId);
     $this->strTemplate = dirname(__FILE__) . '/RecurringPaymentPanel.tpl.php';
     if (!$objAddress) {
         $objAddress = new Address();
     }
     $this->txtFirstName = new QTextBox($this);
     $this->txtFirstName->Name = 'Cardholder Name';
     $this->txtFirstName->Required = true;
     $this->txtFirstName->Text = $strFirstName;
     $this->txtFirstName->Width = '120px';
     $this->txtLastName = new QTextBox($this);
     $this->txtLastName->Name = 'Cardholder Last Name';
     $this->txtLastName->Required = true;
     $this->txtLastName->Text = $strLastName;
     $this->txtLastName->Width = '120px';
     QCryptography::$Key = CRYPTO_KEY;
     $objCrypto = new QCryptography(null, false);
     if ($objRecurringPayment) {
         $strOriginal = $objCrypto->Decrypt($objRecurringPayment->CardHolderName);
         $nameArray = explode(' ', $strOriginal);
         $this->txtFirstName->Text = $nameArray[0];
         $this->txtLastName->Text = $nameArray[1];
     }
     $this->txtAddress1 = new QTextBox($this);
     $this->txtAddress1->Name = 'Address 1';
     if (!$objRecurringPayment) {
         $this->txtAddress1->Text = $objAddress->Address1;
     } else {
         $this->txtAddress1->Text = $objCrypto->Decrypt($objRecurringPayment->Address1);
     }
     $this->txtAddress1->Required = true;
     $this->txtAddress2 = new QTextBox($this);
     $this->txtAddress2->Name = 'Address 2';
     if (!$objRecurringPayment) {
         $this->txtAddress2->Text = $objAddress->Address2;
     } else {
         $this->txtAddress2->Text = $objCrypto->Decrypt($objRecurringPayment->Address2);
     }
     $this->txtCity = new QTextBox($this);
     $this->txtCity->Name = 'City, State and Zip';
     if (!$objRecurringPayment) {
         $this->txtCity->Text = $objAddress->City;
     } else {
         $this->txtCity->Text = $objCrypto->Decrypt($objRecurringPayment->City);
     }
     $this->txtCity->Required = true;
     $this->lstState = new QListBox($this);
     $this->lstState->Name = QApplication::Translate('State');
     $this->lstState->AddItem(QApplication::Translate('- Select One -'), null);
     foreach (UsState::LoadAll(QQ::OrderBy(QQN::UsState()->Name)) as $objUsState) {
         $this->lstState->AddItem($objUsState->Name, $objUsState->Abbreviation, $objAddress->State == $objUsState->Abbreviation);
     }
     $this->lstState->Required = true;
     $this->txtZipCode = new QTextBox($this);
     $this->txtZipCode->Name = 'Zip Code';
     if (!$objRecurringPayment) {
         $this->txtZipCode->Text = $objAddress->ZipCode;
     } else {
         $this->txtZipCode->Text = $objCrypto->Decrypt($objRecurringPayment->Zip);
     }
     $this->txtZipCode->Width = '80px';
     $this->txtZipCode->Required = true;
     $this->lstCcType = new QListBox($this);
     $this->lstCcType->Name = 'Credit Card';
     $this->lstCcType->Required = true;
     $this->lstCcType->AddItem('- Select One -');
     foreach (CreditCardType::$NameArray as $intId => $strName) {
         if ($objRecurringPayment) {
             $this->lstCcType->AddItem($strName, $intId, $objRecurringPayment->CreditCardTypeId == $intId);
         } else {
             $this->lstCcType->AddItem($strName, $intId);
         }
     }
     $this->txtCcNumber = new QTextBox($this);
     $this->txtCcNumber->Name = 'Account Number';
     $this->txtCcNumber->Required = true;
     $this->txtCcNumber->MaxLength = 16;
     if ($objRecurringPayment) {
         $this->txtCcNumber->Text = $objCrypto->Decrypt($objRecurringPayment->AccountNumber);
         $objExpirationDate = $objRecurringPayment->ExpirationDate;
         //$objCrypto->Decrypt($objRecurringPayment->ExpirationDate);
         $intSelectedMonth = substr($objExpirationDate, 0, 2);
         $intSelectedYear = substr($objExpirationDate, 2, 2);
     }
     $this->lstCcExpMonth = new QListBox($this);
     $this->lstCcExpMonth->Name = 'Expiration Date';
     $this->lstCcExpMonth->Required = true;
     $this->lstCcExpMonth->AddItem('- Select One -');
     for ($intMonth = 1; $intMonth <= 12; $intMonth++) {
         $strMonth = date('F', mktime(0, 0, 0, $intMonth, 1, 2000));
         if (!$objRecurringPayment) {
             $this->lstCcExpMonth->AddItem(sprintf('%02s - %s', $intMonth, $strMonth), $intMonth);
         } else {
             $this->lstCcExpMonth->AddItem(sprintf('%02s - %s', $intMonth, $strMonth), $intMonth, $intSelectedMonth == $intMonth);
         }
     }
     $this->lstCcExpYear = new QListBox($this);
     $this->lstCcExpYear->Required = true;
     $this->lstCcExpYear->AddItem('---');
     for ($intYear = 0; $intYear <= 11; $intYear++) {
         $intYearToUse = date('Y') + $intYear;
         $intCmpYear = substr($intYearToUse, 2, 2);
         if (!$objRecurringPayment) {
             $this->lstCcExpYear->AddItem($intYearToUse, $intYearToUse);
         } else {
             $this->lstCcExpYear->AddItem($intYearToUse, $intYearToUse, $intSelectedYear == $intCmpYear);
         }
     }
     $this->txtCcCsc = new QTextBox($this);
     $this->txtCcCsc->Name = 'Security Code (CSC/CVV2)';
     $this->txtCcCsc->Required = true;
     $this->txtCcCsc->Width = '80px';
     $this->txtCcCsc->MinLength = 3;
     $this->txtCcCsc->MaxLength = 4;
     if ($objRecurringPayment) {
         $this->txtCcCsc->Text = $objCrypto->Decrypt($objRecurringPayment->SecurityCode);
     }
 }