Overview

Packages

  • Actions
  • Codegen
  • Controls
    • Base
  • DatabaseAdapters
  • Events
  • None
  • Sessions
  • Tests

Classes

  • AbstractControl_CodeGenerator
  • AjaxTimingForm
  • BasicForm
  • BasicOrmTests
  • BBCodeParser
  • CacheTests
  • CalculatorForm
  • CalculatorWidget
  • ComplexColumn
  • DataRepeaterExample
  • Event
  • ExampleCheckColumn1
  • ExampleCheckColumn2
  • ExampleForm
  • Examples
  • ExampleService
  • ExamplesForm
  • ExampleSingleForm
  • ExpandAsArrayTests
  • HtmlJqDoc
  • InjectForm
  • JavaScriptHelper
  • JqAttributes
  • JqControlGen
  • JqDoc
  • JqIcon
  • Method
  • ModelConnectorTests
  • MyControl
  • MyQSlider_ChangeEvent
  • NavPanel
  • NestedTabForm
  • Option
  • Order
  • PaginatorForm
  • ParamsForm
  • PersistentExampleForm
  • PersonEditPanel
  • PluginEditForm
  • PluginManagerForm
  • Project
  • ProjectEditPanel
  • ProjectListForm
  • ProjectPickerListBox
  • ProjectViewPanel
  • QAbstractCacheProvider
  • QAbstractHtmlTableColumn
  • QAbstractHtmlTableDataColumn
  • QAccordion
  • QAccordion_ActivateEvent
  • QAccordion_BeforeActivateEvent
  • QAccordion_CreateEvent
  • QAccordionBase
  • QAccordionGen
  • QAction
  • QActionControl
  • QAjaxAction
  • QAjaxControlAction
  • QAjaxResponse
  • QAlertAction
  • QApplication
  • QApplicationBase
  • QArchive
  • QAutocomplete
  • QAutocomplete_ChangeEvent
  • QAutocomplete_CloseEvent
  • QAutocomplete_CodeGenerator
  • QAutocomplete_CreateEvent
  • QAutocomplete_FocusEvent
  • QAutocomplete_OpenEvent
  • QAutocomplete_ResponseEvent
  • QAutocomplete_SearchEvent
  • QAutocomplete_SelectEvent
  • QAutocomplete_SourceEvent
  • QAutocompleteBase
  • QAutocompleteBase_CodeGenerator
  • QAutocompleteGen
  • QAutocompleteListItem
  • QBackspaceKeyEvent
  • QBaseClass
  • QBlockControl
  • QBlurControlAction
  • QBlurEvent
  • QBorderCollapse
  • QBorderStyle
  • QBrowserType
  • QButton
  • QButtonBase
  • QCache
  • QCacheDeleteAction
  • QCacheDeleteAllAction
  • QCacheProviderAPC
  • QCacheProviderLocalMemory
  • QCacheProviderLocalMemoryTest
  • QCacheProviderMemcache
  • QCacheProviderNoCache
  • QCacheProviderProxy
  • QCacheSetAction
  • QCalendar
  • QCalendarType
  • QCallType
  • QCausesValidation
  • QCellClickEvent
  • QChangeEvent
  • QCheckBox
  • QCheckBox_CodeGenerator
  • QCheckBoxBase_CodeGenerator
  • QCheckBoxLegacyColumn
  • QCheckBoxList
  • QCheckBoxList_CodeGenerator
  • QCheckBoxListBase_CodeGenerator
  • QClickEvent
  • QCodeGen
  • QCodeGenBase
  • QConfirmAction
  • QContextMenuEvent
  • QControl
  • QControl_CodeGenerator
  • QControlBase
  • QControlBase_CodeGenerator
  • QControlBaseTests
  • QControlCategoryType
  • QControlGrouping
  • QControlLabel
  • QControlProxy
  • QConvertNotation
  • QConvertNotationBase
  • QCrossScripting
  • QCryptography
  • QCss
  • QCssAction
  • QCssClassAction
  • QCssTests
  • QCsvTextBox
  • QCursor
  • QDatabaseBase
  • QDatabaseCodeGen
  • QDatabaseFieldBase
  • QDatabaseFieldType
  • QDatabaseForeignKey
  • QDatabaseIndex
  • QDatabaseResultBase
  • QDatabaseRowBase
  • QDatabaseTests
  • QDataGrid
  • QDataGrid_CheckBoxColumn
  • QDataGrid_CodeGenerator
  • QDataGrid_SortEvent
  • QDataGridBase
  • QDataGridBase_CodeGenerator
  • QDataGridLegacy
  • QDataGridLegacyBase
  • QDataGridLegacyColumn
  • QDataGridLegacyRow
  • QDataGridLegacyRowStyle
  • QDataRepeater
  • QDatepicker
  • QDatepicker_BeforeShowDayEvent
  • QDatepicker_BeforeShowEvent
  • QDatepicker_CalculateWeekEvent
  • QDatepicker_ChangeMonthYearEvent
  • QDatepicker_CloseEvent
  • QDatepicker_SelectEvent
  • QDatepicker_SelectEvent2
  • QDatepickerBase
  • QDatepickerBox
  • QDatepickerBox_BeforeShowDayEvent
  • QDatepickerBox_BeforeShowEvent
  • QDatepickerBox_CalculateWeekEvent
  • QDatepickerBox_ChangeMonthYearEvent
  • QDatepickerBox_CloseEvent
  • QDatepickerBox_CodeGenerator
  • QDatepickerBox_SelectEvent
  • QDatepickerBoxBase
  • QDatepickerBoxBase_CodeGenerator
  • QDatepickerBoxGen
  • QDatepickerGen
  • QDateTime
  • QDateTimePicker
  • QDateTimePicker_CodeGenerator
  • QDateTimePickerBase_CodeGenerator
  • QDateTimePickerFormat
  • QDateTimePickerType
  • QDateTimeSpan
  • QDateTimeTests
  • QDateTimeTextBox
  • QDbBackedFormStateHandler
  • QDbBackedSessionHandler
  • QDialog
  • QDialog_BeforeCloseEvent
  • QDialog_ButtonEvent
  • QDialog_CloseEvent
  • QDialog_CreateEvent
  • QDialog_DragEvent
  • QDialog_DragStartEvent
  • QDialog_DragStopEvent
  • QDialog_FocusEvent
  • QDialog_OpenEvent
  • QDialog_ResizeEvent
  • QDialog_ResizeStartEvent
  • QDialog_ResizeStopEvent
  • QDialogBase
  • QDialogBox
  • QDialogGen
  • QDisplayStyle
  • QDoubleClickEvent
  • QDownArrowKeyEvent
  • QDragDropEvent
  • QDraggable
  • QDraggable_CreateEvent
  • QDraggable_DragEvent
  • QDraggable_StartEvent
  • QDraggable_StopEvent
  • QDraggableBase
  • QDraggableGen
  • QDroppable
  • QDroppable_ActivateEvent
  • QDroppable_CreateEvent
  • QDroppable_DeactivateEvent
  • QDroppable_DropEvent
  • QDroppable_OutEvent
  • QDroppable_OverEvent
  • QDroppableBase
  • QDroppableGen
  • QDropZoneGrouping
  • QEmailAttachment
  • QEmailMessage
  • QEmailServer
  • QEmailStringAttachment
  • QEmailTextBox
  • QEnterKeyEvent
  • QErrorAttribute
  • QEscapeKeyEvent
  • QEvent
  • QFieldset
  • QFile
  • QFileAsset
  • QFileAssetBase
  • QFileAssetDialog
  • QFileAssetType
  • QFileControl
  • QFileFormStateHandler
  • QFilterType
  • QFloatTextBox
  • QFloatTextBox_CodeGenerator
  • QFloatTextBoxBase_CodeGenerator
  • QFocusControlAction
  • QFocusEvent
  • QFocusInEvent
  • QFocusOutEvent
  • QFolder
  • QFontFamily
  • QForm
  • QFormBase
  • QFormGen
  • QFormStateHandler
  • QGridLines
  • QHideCalendarAction
  • QHideDialog
  • QHideDialogBox
  • QHListControl
  • QHListItem
  • QHorizontalAlign
  • QHtml
  • QHtmlAttributeManager
  • QHtmlAttributeManagerBase
  • QHtmlReporter
  • QHtmlTable
  • QHtmlTable_CodeGenerator
  • QHtmlTableBase
  • QHtmlTableCallableColumn
  • QHtmlTableCheckBoxColumn
  • QHtmlTableCheckBoxColumn_ClickEvent
  • QHtmlTableIndexedColumn
  • QHtmlTableLinkColumn
  • QHtmlTableNodeColumn
  • QHtmlTablePropertyColumn
  • QI18n
  • QI18nTests
  • QImageBase
  • QImageBrowser
  • QImageBrowserBase
  • QImageBrowserNav
  • QImageBrowserThumbnails
  • QImageButton
  • QImageControl
  • QImageControlBase
  • QImageFileAsset
  • QImageLabel
  • QImageLabelBase
  • QImageRollover
  • QImageType
  • QIndex
  • QInformixPdoDatabase
  • QInformixPdoDatabaseField
  • QInformixPdoDatabaseResult
  • QInformixPdoDatabaseRow
  • QInputEvent
  • QInstallationValidationResult
  • QInstallationValidator
  • QIntegerTextBox
  • QIntegerTextBox_CodeGenerator
  • QIntegerTextBoxBase_CodeGenerator
  • QJavaScriptAction
  • QJQAction
  • QJQBounceAction
  • QJqButton
  • QJqButton_CreateEvent
  • QJqButtonBase
  • QJqButtonGen
  • QJqCheckBox
  • QJqCheckBox_CreateEvent
  • QJqCheckBoxBase
  • QJqCheckBoxGen
  • QJQHideAction
  • QJQHideEffectAction
  • QJQHighlightAction
  • QJQPulsateAction
  • QJqRadioButton
  • QJqRadioButton_CreateEvent
  • QJqRadioButtonBase
  • QJqRadioButtonGen
  • QJQShakeAction
  • QJQShowAction
  • QJQShowEffectAction
  • QJQSizeAction
  • QJQToggleAction
  • QJQToggleEffectAction
  • QJQTransferAction
  • QJqUiEvent
  • QJqUiPropertyEvent
  • QJsClosure
  • QJsFunction
  • QJsNoQuoteKey
  • QJsParameterList
  • QJsPriority
  • QJsTimer
  • QJsTimerBase
  • QJsVarName
  • QKeyDownEvent
  • QKeyPressEvent
  • QKeyUpEvent
  • QLabel
  • QLabel_CodeGenerator
  • QLabelBase_CodeGenerator
  • QLexer
  • QLinkButton
  • QListBox
  • QListBox_CodeGenerator
  • QListBoxBase
  • QListBoxBase_CodeGenerator
  • QListControl
  • QListControl_CodeGenerator
  • QListControlBase_CodeGenerator
  • QListItem
  • QListItemBase
  • QListItemStyle
  • QManyToManyReference
  • QMenu
  • QMenu_BlurEvent
  • QMenu_CreateEvent
  • QMenu_FocusEvent
  • QMenu_SelectEvent
  • QMenuBase
  • QMenuGen
  • QMimeType
  • QModelConnectorArgumentType
  • QModelConnectorCreateType
  • QModelConnectorEditDlg
  • QModelConnectorOptions
  • QModelConnectorParam
  • QMouseDownEvent
  • QMouseEnterEvent
  • QMouseLeaveEvent
  • QMouseMoveEvent
  • QMouseOutEvent
  • QMouseOverEvent
  • QMouseUpEvent
  • QMultiLevelCacheProvider
  • QMySqlDatabase
  • QMySqlDatabaseField
  • QMySqlDatabaseResult
  • QMySqli5ClusterDatabase
  • QMySqli5Database
  • QMySqli5DatabaseField
  • QMySqli5DatabaseResult
  • QMySqliDatabase
  • QMySqliDatabaseField
  • QMySqliDatabaseResult
  • QMySqliDatabaseRow
  • QNoScriptAjaxAction
  • QNumericTextBox
  • QOnEvent
  • QOracleDatabase
  • QOracleDatabaseField
  • QOracleDatabaseResult
  • QOracleDatabaseRow
  • QOrderedListType
  • QOverflow
  • QPaginatedControl
  • QPaginator
  • QPaginatorBase
  • QPanel
  • QPartialQueryBuilder
  • QPdoDatabase
  • QPdoDatabaseResult
  • QPgConditionILike
  • QPgConditionJsonContains
  • QPgQ
  • QPosition
  • QPostgreSqlDatabase
  • QPostgreSqlDatabaseField
  • QPostgreSqlDatabaseResult
  • QPostgreSqlDatabaseRow
  • QPostgreSqlPdoDatabase
  • QPostgreSqlPdoDatabaseField
  • QPostgreSqlPdoDatabaseResult
  • QPostgreSqlPdoDatabaseRow
  • QProgressbar
  • QProgressbar_ChangeEvent
  • QProgressbar_CompleteEvent
  • QProgressbar_CreateEvent
  • QProgressbarBase
  • QProgressbarGen
  • QQ
  • QQAggregationClause
  • QQAliasTests
  • QQAssociationNode
  • QQAverage
  • QQClause
  • QQColumnNode
  • QQCondition
  • QQConditionAll
  • QQConditionAnd
  • QQConditionBetween
  • QQConditionComparison
  • QQConditionEqual
  • QQConditionExists
  • QQConditionGreaterOrEqual
  • QQConditionGreaterThan
  • QQConditionIn
  • QQConditionIsNotNull
  • QQConditionIsNull
  • QQConditionLessOrEqual
  • QQConditionLessThan
  • QQConditionLike
  • QQConditionLogical
  • QQConditionNone
  • QQConditionNot
  • QQConditionNotBetween
  • QQConditionNotEqual
  • QQConditionNotExists
  • QQConditionNotIn
  • QQConditionNotLike
  • QQConditionOr
  • QQCount
  • QQDistinct
  • QQExpand
  • QQExpandAsArray
  • QQExpandVirtualNode
  • QQFuncTests
  • QQFunctionNode
  • QQGroupBy
  • QQHavingClause
  • QQLimitInfo
  • QQMathNode
  • QQMathOpTests
  • QQMaximum
  • QQMinimum
  • QQNamedValue
  • QQNode
  • QQNoParentNode
  • QQOrderBy
  • QQReverseReferenceNode
  • QQSelect
  • QQSubQueryCountNode
  • QQSubQueryNode
  • QQSubQuerySqlNode
  • QQSum
  • QQTableNode
  • QQuery
  • QQueryBuilder
  • QQueryExpansion
  • QQVirtualNode
  • QRadioButton
  • QRadioButtonList
  • QRadioButtonList_CodeGenerator
  • QRadioButtonListBase_CodeGenerator
  • QRedirectAction
  • QReference
  • QRegex
  • QRegisterClickPositionAction
  • QRepeatDirection
  • QRequestMode
  • QResetTimerAction
  • QResizable
  • QResizable_CreateEvent
  • QResizable_ResizeEvent
  • QResizable_StartEvent
  • QResizable_StopEvent
  • QResizableBase
  • QResizableGen
  • QResizeHandleDirection
  • QRestServiceCodeGen
  • QReverseReference
  • QRssCategory
  • QRssFeed
  • QRssImage
  • QRssItem
  • QSampleControl
  • QSampleTranslation
  • QSelectable
  • QSelectable_CreateEvent
  • QSelectable_SelectedEvent
  • QSelectable_SelectingEvent
  • QSelectable_StartEvent
  • QSelectable_StopEvent
  • QSelectable_UnselectedEvent
  • QSelectable_UnselectingEvent
  • QSelectableBase
  • QSelectableGen
  • QSelectControlAction
  • QSelectEvent
  • QSelectionMode
  • QSelectMenu
  • QSelectMenu_ChangeEvent
  • QSelectMenu_CloseEvent
  • QSelectMenu_CreateEvent
  • QSelectMenu_FocusEvent
  • QSelectMenu_OpenEvent
  • QSelectMenu_SelectEvent
  • QSelectMenuBase
  • QSelectMenuGen
  • QServerAction
  • QServerControlAction
  • QSessionFormStateHandler
  • QSetValueAction
  • QShowCalendarAction
  • QShowDialog
  • QShowDialogBox
  • QSlider
  • QSlider_ChangeEvent
  • QSlider_CodeGenerator
  • QSlider_CreateEvent
  • QSlider_SlideEvent
  • QSlider_StartEvent
  • QSlider_StopEvent
  • QSliderBase
  • QSliderBase_CodeGenerator
  • QSliderGen
  • QSoapMethod
  • QSoapParameter
  • QSoapService
  • QSortable
  • QSortable_ActivateEvent
  • QSortable_BeforeStopEvent
  • QSortable_ChangeEvent
  • QSortable_CreateEvent
  • QSortable_DeactivateEvent
  • QSortable_OutEvent
  • QSortable_OverEvent
  • QSortable_ReceiveEvent
  • QSortable_RemoveEvent
  • QSortable_SortEvent
  • QSortable_StartEvent
  • QSortable_StopEvent
  • QSortable_UpdateEvent
  • QSortableBase
  • QSortableGen
  • QSpinner
  • QSpinner_ChangeEvent
  • QSpinner_CreateEvent
  • QSpinner_SpinEvent
  • QSpinner_StartEvent
  • QSpinner_StopEvent
  • QSpinnerBase
  • QSpinnerGen
  • QSqlColumn
  • QSqLite3PdoDatabase
  • QSqLite3PdoDatabaseField
  • QSqLite3PdoDatabaseResult
  • QSqLite3PdoDatabaseRow
  • QSqlServer2005Database
  • QSqlServer2005DatabaseField
  • QSqlServer2005DatabaseResult
  • QSqlServer2005DatabaseRow
  • QSqlServerDatabase
  • QSqlServerDatabaseField
  • QSqlServerDatabaseResult
  • QSqlServerDatabaseRow
  • QSqlTable
  • QStack
  • QStopPropagationAction
  • QString
  • QStringTest
  • QTabKeyEvent
  • QTabs
  • QTabs_ActivateEvent
  • QTabs_BeforeActivateEvent
  • QTabs_BeforeLoadEvent
  • QTabs_CreateEvent
  • QTabs_LoadEvent
  • QTabsBase
  • QTabsGen
  • QTag
  • QTagStyler
  • QTerminateAction
  • QTestControl
  • QTestForm
  • QTextAlign
  • QTextBox
  • QTextBox_CodeGenerator
  • QTextBoxBase
  • QTextBoxBase_CodeGenerator
  • QTextMode
  • QTimer
  • QTimerExpiredEvent
  • QTimerTests
  • QToggleCssClassAction
  • QToggleDisplayAction
  • QToggleEnableAction
  • QTranslationPoParser
  • QTreeNav
  • QTreeNavItem
  • QType
  • QTypeTable
  • QTypeTests
  • QUnitTestCaseBase
  • QUnorderedListStyle
  • QUpArrowKeyEvent
  • QUrlTextBox
  • QVerticalAlign
  • QVirtualAttributeColumn
  • QWaitIcon
  • QWatcher
  • QWatcherBase
  • QWatcherCache
  • QWatcherDB
  • QWatcherNone
  • QWriteBox
  • RecordsSummary
  • RefreshForm
  • SampleComposite
  • SampleForm
  • SelectableLabel
  • SelectForm
  • SpeedForm
  • TestImageBrowser
  • UrlForm

Interfaces

  • ICacheAction
  • QDataList_CodeGenerator_Interface
  • QTranslationBase

Traits

  • QDataBinder
  • QListItemManager
  • QModelTrait

Exceptions

  • QCallerException
  • QCrossScriptingException
  • QCryptographyException
  • QDatabaseExceptionBase
  • QDataBindException
  • QDateTimeNullException
  • QEmailException
  • QIndexOutOfRangeException
  • QInformixPdoDatabaseException
  • QInvalidCastException
  • QInvalidFormStateException
  • QMySqliDatabaseException
  • QOptimisticLockingException
  • QOracleDatabaseException
  • QPdoDatabaseException
  • QPoParserException
  • QPostgreSqlDatabaseException
  • QPostgreSqlPdoDatabaseException
  • QRemoteAdminDeniedException
  • QSqLite3PdoDatabaseException
  • QSqlServer2005DatabaseException
  • QSqlServerDatabaseException
  • QUndefinedMethodException
  • QUndefinedPrimaryKeyException
  • QUndefinedPropertyException

Functions

  • __database_check_error
  • __QForm_EvaluateTemplate_ObHandler
  • _b
  • _indent
  • _nl
  • _p
  • _r
  • _t
  • _tp
  • _tr
  • array_trim
  • beginsWith
  • CamelCaseFromDash
  • CastToInt
  • DataGridEvalHandleError
  • DisplayMonospacedText
  • endsWith
  • GO_BACK
  • jq_anytime_gen
  • jq_control_gen
  • jq_inc_gen
  • jq_indent
  • PrintExplainStatement
  • PrintInstructions
  • QcubedHandleCodeGenParseError
  • QcubedHandleError
  • QcubedHandleException
  • QCubedShutdown
  • QDateTimeErrorHandler
  • trimOffEnd
  • trimOffFront
  • Overview
  • Package
  • Class
  1: <?php
  2:     // Requires libmcrypt v2.4.x or higher
  3: 
  4:     /**
  5:      * Class QCryptographyException: If an exception occurs in the QCryptography class, we use this one to handle
  6:      */
  7:     class QCryptographyException extends QCallerException {
  8:     }
  9: 
 10:     /**
 11:      * Class QCryptography: Helps in encrypting and decrypting data
 12:      * It depends on the mcrypt module.
 13:      *
 14:      * While this module IS serializeable, the information it contains in serialized form is not secure and can be used
 15:      * to decrypt encrypted items. So, make sure you either encrypt the serialized results, or store the results in a
 16:      * secure location. That means, if you are using this in a form object, you must make sure your formstates are
 17:      * not visible to the public, or they are encrypted, since the serialized version of this object will be in the formstate.
 18:      *
 19:      * Refer: http://php.net/manual/en/book.mcrypt.php
 20:      */
 21:     class QCryptography extends QBaseClass {
 22:         /** @var resource Mcrypt algorithm module resource */
 23:         protected $objMcryptModule;
 24:         /** @var bool Are we going to use Base 64 encoding? */
 25:         protected $blnBase64;
 26:         /** @var string Key to be used for encryption/decryption - used for mycrypt_generic_init */
 27:         protected $strKey;
 28:         /** @var string Initialization vector for the algorithm */
 29:         protected $strIv; // Note that this is NOT used in ECB, the default mode.
 30:         /** @var  string Cipher to use when creating the encryption object */
 31:         protected $strCipher;
 32:         /** @var  string Mode to use when creating the encryption object */
 33:         protected $strMode;
 34:         /** @var  string Random source to use when creating IVs */
 35:         protected $strRandomSource;
 36: 
 37: 
 38:         /**
 39:          * Default Base64 mode for any new QCryptography instances that get constructed.
 40:          * This is similar to MIME-based Base64 encoding/decoding, but is safe to use
 41:          * in URLs, POST/GET data, and any other text-based stream.
 42:          * Note that by setting Base64 to true, it will result in an encrypted data string
 43:          * that is 33% larger.
 44:          *
 45:          * @var string Base64
 46:          */
 47:         public static $Base64 = true;
 48: 
 49:         /**
 50:          * Default Key for any new QCryptography instances that get constructed
 51:          *
 52:          * @var string Key
 53:          */
 54:         public static $Key = "qc0Do!d3F@lT.k3Y";
 55: 
 56:         /**
 57:          * The Random Number Generator the library uses to generate the IV:
 58:          *  - MCRYPT_DEV_RANDOM = /dev/random (only on *nix systems)
 59:          *  - MCRYPT_DEV_URANDOM = /dev/urandom (only on *nix systems)
 60:          *  - MCRYPT_RAND = the internal PHP srand() mechanism
 61:          * (on Windows, you *must* use MCRYPT_RAND, b/c /dev/random and /dev/urandom doesn't exist)
 62:          * TODO: there appears to be some /dev/random locking issues on the QCubed development
 63:          * environment (using Fedora Core 3 with PHP 5.0.4 and LibMcrypt 2.5.7).  Because of this,
 64:          * we are using MCRYPT_RAND be default.  Feel free to change to to /dev/*random at your own risk.
 65:          *
 66:          * @param null|string $strKey          Encryption key
 67:          * @param null|bool   $blnBase64       Are we going to use Base 64 encoded data?
 68:          * @param null|string $strCipher       Cipher to be used (default is MCRYPT_TRIPLEDES)
 69:          * @param null|string $strMode         Mode (default is MCRYPT_MODE_ECB)
 70:          * @param null|string $strRandomSource Random source (default is MCRYPT_RAND)
 71:          *
 72:          * @throws Exception
 73:          * @throws QCallerException
 74:          * @throws QCryptographyException
 75:          */
 76:         public function __construct($strKey = null, $blnBase64 = null, $strCipher = null, $strMode = null,
 77:                                     $strRandomSource = null) {
 78:             if (!function_exists('mcrypt_module_open')) {
 79:                 throw new QCryptographyException("PHP cryptography components (libmcrypt module) are not installed");
 80:             }
 81: 
 82:             // Get the Key
 83:             if (is_null($strKey)) {
 84:                 $strKey = self::$Key;
 85:             }
 86: 
 87:             // Get the Base64 Flag
 88:             try {
 89:                 if (is_null($blnBase64)) {
 90:                     $this->blnBase64 = QType::Cast(self::$Base64, QType::Boolean);
 91:                 } else {
 92:                     $this->blnBase64 = QType::Cast($blnBase64, QType::Boolean);
 93:                 }
 94:             } catch (QCallerException $objExc) {
 95:                 $objExc->IncrementOffset();
 96:                 throw $objExc;
 97:             }
 98: 
 99:             // Get the Cipher
100:             if (is_null($strCipher)) {
101:                 $this->strCipher = MCRYPT_TRIPLEDES;
102:             } else {
103:                 $this->strCipher = $strCipher;
104:             }
105: 
106:             // Get the Mode
107:             if (is_null($strMode)) {
108:                 $this->strMode = MCRYPT_MODE_ECB;
109:             } else {
110:                 $this->strMode = $strMode;
111:             }
112: 
113:             if (is_null($strRandomSource)) {
114:                 $this->strRandomSource = MCRYPT_RAND;
115:             } else {
116:                 $this->strRandomSource = $strRandomSource;
117:             }
118: 
119:             $this->objMcryptModule = mcrypt_module_open($this->strCipher, null, $this->strMode, null);
120:             if (!$this->objMcryptModule) {
121:                 throw new QCryptographyException('Unable to open LibMcrypt Module');
122:             }
123: 
124:             // Determine IV Size
125:             $intIvSize = mcrypt_enc_get_iv_size($this->objMcryptModule);
126: 
127:             // Create the IV
128:             if ($intIvSize) {
129:                 if ($this->strRandomSource != MCRYPT_RAND) {
130:                     // Ignore All Warnings
131:                     set_error_handler('QcubedHandleError', 0);
132:                     $intCurrentLevel = error_reporting();
133:                     error_reporting(0);
134:                     $strIv = mcrypt_create_iv($intIvSize, $this->strRandomSource);
135:                     error_reporting($intCurrentLevel);
136:                     restore_error_handler();
137: 
138:                     // If the RandomNumGenerator didn't work, we revert back to using MCRYPT_RAND
139:                     if (strlen($strIv) != $intIvSize) {
140:                         srand();
141:                         $strIv = mcrypt_create_iv($intIvSize, MCRYPT_RAND);
142:                     }
143:                 } else {
144:                     srand();
145:                     $strIv = mcrypt_create_iv($intIvSize, MCRYPT_RAND);
146:                 }
147:                 $this->strIv = $strIv;
148:             }
149: 
150:             // Determine KeySize length
151:             $intKeySize = mcrypt_enc_get_key_size($this->objMcryptModule);
152: 
153:             // Create the Key Based on Key Passed In
154:             $this->strKey = substr(md5($strKey), 0, $intKeySize);
155:         }
156: 
157:         /**
158:          * Encrypt the data (depends on the value of class members)
159:          * @param string $strData
160:          *
161:          * @return mixed|string
162:          * @throws QCryptographyException
163:          */
164:         public function Encrypt($strData) {
165:             // Initialize Encryption
166:             $intReturnValue = mcrypt_generic_init($this->objMcryptModule, $this->strKey, $this->strIv);
167:             if (($intReturnValue === false) || ($intReturnValue < 0)) {
168:                 throw new QCryptographyException('Incorrect Parameters used in LibMcrypt Initialization');
169:             }
170:             // Add Length to strData
171:             $strData = strlen($strData) . '/' . $strData;
172: 
173:             $strEncryptedData = mcrypt_generic($this->objMcryptModule, $strData);
174:             if ($this->blnBase64) {
175:                 $strEncryptedData = base64_encode($strEncryptedData);
176:                 $strEncryptedData = str_replace('+', '-', $strEncryptedData);
177:                 $strEncryptedData = str_replace('/', '_', $strEncryptedData);
178:                 $strEncryptedData = str_replace('=', '', $strEncryptedData);
179:             }
180: 
181: 
182:             // Deinitialize Encryption
183:             if (!mcrypt_generic_deinit($this->objMcryptModule)) {
184:                 throw new QCryptographyException('Unable to deinitialize encryption buffer');
185:             }
186: 
187:             return $strEncryptedData;
188:         }
189: 
190:         /**
191:          * Decrypt the data (depends on the value of class memebers)
192:          * @param string $strEncryptedData
193:          *
194:          * @return string
195:          * @throws QCryptographyException
196:          */
197:         public function Decrypt($strEncryptedData) {
198:             // Initialize Encryption
199:             $intReturnValue = mcrypt_generic_init($this->objMcryptModule, $this->strKey, $this->strIv);
200:             if (($intReturnValue === false) || ($intReturnValue < 0)) {
201:                 throw new QCryptographyException('Incorrect Parameters used in LibMcrypt Initialization');
202:             }
203: 
204:             if ($this->blnBase64) {
205:                 $strEncryptedData = str_replace('_', '/', $strEncryptedData);
206:                 $strEncryptedData = str_replace('-', '+', $strEncryptedData);
207:                 $strEncryptedData = base64_decode($strEncryptedData);
208:             }
209:             $intBlockSize = mcrypt_enc_get_block_size($this->objMcryptModule);
210:             $strDecryptedData = mdecrypt_generic($this->objMcryptModule, $strEncryptedData);
211: 
212:             // Figure Out Length and Truncate
213:             $intPosition = strpos($strDecryptedData, '/');
214:             if (!$intPosition) {
215:                 throw new QCryptographyException('Invalid Length Header in Decrypted Data');
216:             }
217:             $intLength = substr($strDecryptedData, 0, $intPosition);
218:             $strDecryptedData = substr($strDecryptedData, $intPosition + 1);
219:             $strDecryptedData = substr($strDecryptedData, 0, $intLength);
220: 
221:             // Deinitialize Encryption
222:             if (!mcrypt_generic_deinit($this->objMcryptModule)) {
223:                 throw new QCryptographyException('Unable to deinitialize encryption buffer');
224:             }
225: 
226:             return $strDecryptedData;
227:         }
228: 
229:         /**
230:          * Encrypt a file (depends on the value of class memebers)
231:          *
232:          * @param string $strFile Path of the file to be encrypted
233:          *
234:          * @return mixed|string
235:          * @throws QCallerException|QCryptographyException
236:          */
237:         public function EncryptFile($strFile) {
238:             if (file_exists($strFile)) {
239:                 $strData = file_get_contents($strFile);
240: 
241:                 return $this->Encrypt($strData);
242:             } else {
243:                 throw new QCallerException('File does not exist: ' . $strFile);
244:             }
245:         }
246: 
247:         /**
248:          * Decrypt a file (depends on the value of class memebers)
249:          *
250:          * @param string $strFile File to be decrypted
251:          *
252:          * @return string
253:          * @throws QCallerException|QCryptographyException
254:          */
255:         public function DecryptFile($strFile) {
256:             if (file_exists($strFile)) {
257:                 $strEncryptedData = file_get_contents($strFile);
258: 
259:                 return $this->Decrypt($strEncryptedData);
260:             } else {
261:                 throw new QCallerException('File does not exist: ' . $strFile);
262:             }
263:         }
264: 
265:         /**
266:          * Closes the mcrypt module
267:          * (Some methods just want to watch the world burn!)
268:          */
269:         public function __destruct() {
270:             if ($this->objMcryptModule) {
271:                 // Ignore All Warnings
272:                 set_error_handler('QcubedHandleError', 0);
273:                 $intCurrentLevel = error_reporting();
274:                 error_reporting(0);
275:                 mcrypt_module_close($this->objMcryptModule);
276:                 error_reporting($intCurrentLevel);
277:                 restore_error_handler();
278:             }
279:         }
280: 
281:         public function __sleep() {
282:             return array_diff(array_keys(get_object_vars($this)), array('objMcryptModule')); // can't serialize the module, must recreate
283:         }
284: 
285:         public function __wakeup() {
286:             $this->objMcryptModule = mcrypt_module_open($this->strCipher, null, $this->strMode, null);
287:         }
288: 
289:     }
API documentation generated by ApiGen