classes/php5_classes/Crypt.class.php

Properties

Description

Holds the geoCrypt class, which is used to encrypt data such as CC numbers.

Classes

geoCrypt

Description

Class to use for encrypting information that needs to be able to be retrieved later.
The goal of this encryption, is to make it sufficiently difficult to try to figure out what the key is (and thus be able to decrypt the encrypted string), when an untrusted party gains access to the encrypted data. This will detect what type of encryption the server supports, and use that encryption to encrypt the data. This means that if the server changes, and the new server does not have the same capabilities as the previous one, it may make the data not recoverable (unless transfered to a server that does have sufficient capabilites to decrypt it)

Methods

__construct, _decrypt, _encrypt, _generateKey, _process, decrypt, encrypt, generateRandomKey, getCypherUsed, getEncryptedText, getPlainText, setCypherUsed, setEncryptedText, setKeyData, setPlainText,

__construct( ) : n/a

Description

Sets up defaults used for encrypting/decrypting information

Return value

Type Description
n/a n/a

_decrypt( ) : n/a

Description

Decrypts _encryptedText and stores the decrypted value in _plainText (to be retrieved by getPlainText()) using the cypher method set in _cypherUsed
This function MUST be called after _process() is called, or it may act un-predictably.

Return value

Type Description
n/a n/a

_encrypt( ) : n/a

Description

Encrypts _plainText and stores the encrypted value in _encryptedText (to be retrieved by getEncryptedText()) using the cypher method set in _cypherUsed
This function MUST be called after _process() is called, or it may act un-predictably.

Return value

Type Description
n/a n/a

_generateKey( ) : n/a

Description

Takes _keyData as set by setKeyData() and generates a string key from it, and stores that key in _keyString to be used by _encrypt() and _decrypt(). The same array of data will always generate the same key string.

Return value

Type Description
n/a n/a

_process( ) : n/a

Description

Sets up any un-set stuff, and encyrpts or decrypts depending on which vars are set. Only does stuf that needs to be done, so safe to call multiple times.

Return value

Type Description
n/a n/a

decrypt( string   $text, mixed   $key, string   $cypher = null, ) : string

Description

Convenience function, decrypts the given string using the key provided, and returns the decrypted text.

Arguments

Name Type Description Default
$text string
$key mixed

Either an array of strings to use to generate a key, or a string key

$cypher string

Cypher algorithm to use, if not specified the default for this server's capabilities will be used.

null

Return value

Type Description
string

encrypt( string   $text, mixed   $key, string   $cypher = null, ) : string

Description

Convenience function, encrypts the given string using the key provided, and returns the encrypted text.
NOT recommended if the cypher used to encrypt the data is needed to be known

Arguments

Name Type Description Default
$text string
$key mixed

Either an array of strings to use to generate a key, or a string key

$cypher string

Cypher algorithm to use, if not specified the default for this server's capabilities will be used.

null

Return value

Type Description
string

generateRandomKey( int   $min_key_length = 30, int   $max_key_length = 45, ) : string

Description

Generates a "random" key using PHP's mt_rand function.

Arguments

Name Type Description Default
$min_key_length int

Minimum number of chars for the length of the key

30
$max_key_length int

Max number of chars for the length of the key

45

Return value

Type Description
string

getCypherUsed( ) : string

Description

Gets the cypher used during the last encryption/decryption.
If no encryption/decryption has been done yet, it returns the default used by the system when none is specified.

Return value

Type Description
string

getEncryptedText( ) : string

Description

get the encrypted text

Return value

Type Description
string

getPlainText( ) : string

Description

Gets the plain text. If the encrypted text was previously set, it will automatically decrypt that using the key data (if set).

Return value

Type Description
string

setCypherUsed( string   $cypher = self::CYPHER_BASIC, ) : n/a

Description

Manually set the cypher to be used. Typically you only set the cypher when decrypting.

Arguments

Name Type Description Default
$cypher string self::CYPHER_BASIC

Return value

Type Description
n/a n/a

setEncryptedText( string   $text, ) : n/a

Description

Sets the encrypted text, so that it can be decrypted and returned by getPlainText

Arguments

Name Type Description Default
$text string

Return value

Type Description
n/a n/a

setKeyData( array   $key_data, ) : n/a

Description

Sets the key's data. This data will be used to generate a text key, in such a way so that the same data will produce the same key. Then you can store the data instead of storing the plain-text key, so it will not be obvious that the data was used (in part) to generate the key.

Arguments

Name Type Description Default
$key_data array

Suggested use: Pass an array of user or transaction data (including things like ip used at time of transaction, or time transaction took place), then store the same data so that it can be retrieved later. Then you pass the same data at a later time to be able to decrypt the data again.

Return value

Type Description
n/a n/a

setPlainText( string   $text, ) : n/a

Description

Set the plain text that will be encrypted.

Arguments

Name Type Description Default
$text string

Return value

Type Description
n/a n/a

Properties

$_cypherUsed, $_defaultCypher, $_encryptedText, $_keyData, $_keyString, $_plainText, $_siteKey, $_validCyphers,

string  protected  $_cypherUsed =

The cypher algorithm used (or to be used) when encrypting/decrypting


string  protected  static $_defaultCypher =

Server capabilities are gauged, to determine the best cypher method (the encryption algorithm). The method used will be one of the constants prepended with CYPHER_ - it is static so that it does not have to be re-detected multiple times in one page load.


string  protected  $_encryptedText =

The encrypted text


array  protected  $_keyData =

The data to be used to generate a key from


string  protected  $_keyString =

The real key used, this should not be stored anywhere, but rather re-generated by taking the same data used when encrypting to re-generate it


string  protected  $_plainText =

The plain text


string  protected  static $_siteKey =

The site key, used as salt for each key generated


array  protected  static $_validCyphers = array(self::CYPHER_BASIC)

Array of allowed cypher types


Constants

  CYPHER_BASIC = 'basic'

The "basic" type of cypher, this is the "fallback" if no other encryption algorithms are possible with the server.


  DEBUG = false

Set this to true to enable debug messages for troubleshooting or creating new cypher types. Do NOT leave this at 1 as it can make data that is supposed to be encrypted be stored in a log file in plain-text, and that is probably not a very good thing.
In fact, it would be a very bad thing on production sites, so don't do it on a production site. When adding new debug messages: Be sure to use ONLY the keyword "CRYPT", an example call would look like: if (self::DEBUG) trigger_error('DEBUG CRYPT: Debug message!');

Documentation was generated by phpDocumentor 2.2.0 .

Namespaces

  • global

    Packages

    • Default
      • ExampleAddon
        • addon_example_admin
          In charge of doing stuff on the admin side, this is optional.
        • addon_example_info
          Required class for addons, this is the Addon information class, used by the addon system to determine what the addon can do. Also contains info about the addon that can be viewed in the addon management page in the admin.
        • addon_example_pages
          Addon page class, used by the addon system to display pages on the client side.
        • addon_example_setup
          This class is not required. If it, and the function for a particular routine exist, then that function will be called IN ADDITION TO the automated routines of the addon framework.
        • addon_example_tags
          Expects one function for each tag. Function name should be the same as the tag name. Can also have a constructor if anything needs to be constructed.
        • addon_example_util
          This is where to put functions that the main part of the addon will use.
        • eWidgetOrderItem
          This order item is designed to allow users on your site to purchase an eWidget.
      • System
        • DataAccess
          This is the main Database access object.
        • Singleton
          Singleton method class
        • _templateOrderItem
          Developers: use this file as a template to create a new order item.
        • _templatePaymentGateway
          This is the "developer template" payment gateway handler, a developer could use this file as a starting point for creating a new payment gateway in the system.
        • geoAPI
          The main system class for receiving and handling remote API calls, this acts as a translation layer between the communication with the "outside" and each API call.
        • geoAddon
          This is the class that handles anything and everything to do with addons.
        • geoArrayTools
          Utility functions for manipulating arrays
        • geoBrowse
          Contains functions common to browsing listings
        • geoBrowsingFilter
          System for activating, storing, and deactivating browsing filters.
        • geoCJAX
          Class that wraps the CJAX_FRAMEWORK, used to get the CJAX class.
        • geoCache
          This is the main part of the Geo cache system, it does all the "low level" stuff like writing files and escaping cache data.
        • geoCacheModule
          Part of Geo Cache system, specifically tuned to work best with cacheing module data (which will be an array).
        • geoCachePage
          Cache system specifically tuned to work best with cacheing output of pages and modules
        • geoCacheSetting
          Part of Geo Cache system, specifically tuned to work best with cacheing site-wide key=value type settings.
        • geoCacheText
          Part of Geo Cache system, this part specifically tuned to work best with cacheing language specific messages.
        • geoCalendar
          Holds utility method(s) for manipulating stuff dealing with calendar selector.
        • geoCart
          This class is behind the cart, loading all the order items and such and displaying, and processing all the different pages.
        • geoCategory
          Utility class that holds various methods to do stuff with categories in the system.
        • geoCombineResources
          This class helps to combine CSS and JS files, minify them, and optionally compress them.
        • geoCron
          This is the cron job backend, it handles all the communication and security and all that.
        • geoCrypt
          Class to use for encrypting information that needs to be able to be retrieved later.
        • geoDate
          Holds utility method(s) for manipulating stuff dealing with dates.
        • geoEmail
          Class that sends out e-mails.
        • geoFields
          Class that holds settings information for fields to use.
        • geoFieldsField
          A mini object to hold data about a specific field.
        • geoFile
          As the name implies, this is used for file-based utility methods.
        • geoFilter
          A few utility methods, good for filtering stuff.
        • geoFormatString
          Used to display a message nice and pretty, we'll probably be getting rid of this class though so don't go crazy using it.
        • geoHTML
          Class to generate chunks of HTML that are very common, used the most in the admin panel.
        • geoImage
          This class is responsible for a lot of the image processing, along with other aspects like generating the image tag for thumbnails.
        • geoInvoice
          This is the invoice object representing an invoice in the system.
        • geoLeveledField
          Class for doing common things with leveled fields.
        • geoListing
          A listing object, basically a container object for particular listing.
        • geoListingDisplay
          This is basically a container that is responsible for helping to display {listing .
        • geoListingFeed
          Class that helps to render RSS or other types of feeds based on list of listings.
        • geoMaster
          This is dedicated class for getting the value of, and setting, the various "master switches" within the software. Since this is meant as an easy way to get the values of master switches, most of the methods are static.
        • geoNumber
          Utility functions relating to number conversion/manipulation/validation ect.
        • geoOrder
          The geoOrder object, an object representation of an order in the system.
        • geoOrderItem
          The class that all order items must extend.
        • geoPC
          Used for login credential validation, password hashing, etc. along with software licensing.
        • geoPagination
          Utility functions useful for generating pagination of a results page such as when browing ads or searching
        • geoPaymentGateway
          This class should be extended by each different payment gateway, this will have some default functions that each gateway will inherit, and also has a few final static methods used by the system to affect all order items.
        • geoPlanItem
          A container to hold settings for a particular order item type, according to price plan ID, and optionally category ID for category specific settings.
        • geoRecurringBilling
          The geoRecurringBilling object, an object representation of a recurring billing in the system.
        • geoRegion
          Stuff for regions and sub-regions.
        • geoRegistry
          Handy little object, can be used to set registry type settings.
        • geoSearchUtils
          Class for search utilities.
        • geoSellerBuyer
          Handles back-end for the seller/buyer payment gateways, to allow the buyer to more easily pay the seller for a won auction. This handles the underlying system, but the actual work is done by individual seller/buyer gateways, for instance the Paypal buy-now functionality.
        • geoSession
          Manages session storage and session cookies for user sessions.
        • geoString
          Utility functions relating to languages and string manipulation.
        • geoStringData
          This class is to store accented chars, to be used by {@link geoString::removeAccents()}, mainly to keep the String.class.php file un-cluttered.
        • geoTable
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRow
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRowset
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableSelect
          Class used to generate a select query, useful when multiple areas want to affect a single query, for instance when generating a search query and there are addons involved.
        • geoTables
          Used to hold database table names, used throughout the code.
        • geoTemplate
          Template object that extends the Smarty class (a 3rd party library) to enable using templates to display things.
        • geoTransaction
          This is the object used for a transaction in the order and invoice system.
        • geoUser
          An object representative of a certain user in the system.
        • geoUserRating
          Store, retrieve, and display inter-user ratings
        • geoUtil
          Misc utility functions
        • geoView
          As the name implies, this is used for creating the page view. It does take a little setup (like any class), the setup is normally done in the display_page method in geoSite, or display_page in geoAdmin if displaying a page in the admin.
        • iApiTransport
          Interface for API Transports, a transport must implement this interface for the system to use it.
        • iOrderItem
          You cannot have abstract static functions, so instead need to have an interface to force the given static functions to be defined.
        • metaDbTables
          Used so that old locations that use the old name geoTables will still work.