Class Crypt

Description

Encrypts and decrypts data using the mcrypt extension

The Crypt class is an abstraction layer over the functions provided by the mcrypt extension, which supports a wide variety of algorithms to encrypt/decrypt data, such as DES, TripleDES, Blowfish, and much more.

Example:

  1.  $crypt new Crypt();
  2.  $crypt->setCipher(MCRYPT_BLOWFISH);
  3.  $crypt->setCipherMode(MCRYPT_MODE_CBC);
  4.  $crypt->setKey('this is the key');
  5.  $encrypted $crypt->engineEncrypt('secret data');
  6.  $decrypted $crypt->engineDecrypt($encrypted);

Located in /core/security/Crypt.class.php (line 62)

PHP2Go
   |
   --Crypt
Variable Summary
string $cipher
string $cipherMode
resource $handle
string $iv
string $key
Method Summary
void clearKey ()
string|bool engineDecrypt (string $data, [string $saveTo = ''])
bool engineDecryptFile (string $inFileName, string $outFileName)
string|bool engineEncrypt (string $data, [string $saveTo = ''])
bool engineEncryptFile (string $inFileName, string $outFileName)
string getCipher ()
array getCipherList ()
string getCipherMode ()
string getKey ()
array getModeList ()
bool setCipher (string $cipher)
bool setCipherMode (string $cipherMode)
void setKey (string $key)
bool _initialize ()
Variables
string $cipher = CRYPT_DEFAULT_CIPHER (line 69)

Current cipher algorithm

string $cipherMode = CRYPT_DEFAULT_MODE (line 76)

Current cipher mode

resource $handle (line 91)

Internal handle, provided my mcrypt_generic_init()

  • access: private
string $iv (line 99)

Initialization vector

  • access: private
string $key (line 83)

Cipher key

Methods
Constructor Crypt (line 106)

Class constructor

Crypt Crypt ()
clearKey (line 210)

Unset the cipher key

void clearKey ()
engineDecrypt (line 282)

Decrypts the passed $data, using current configurations for cipher, cipher mode and cipher key

string|bool engineDecrypt (string $data, [string $saveTo = ''])
  • string $data: Data to decrypt
  • string $saveTo: Optional file where decrypted data must be saved
engineDecryptFile (line 315)

Decrypts the contents of a file, saving the results in another file

bool engineDecryptFile (string $inFileName, string $outFileName)
  • string $inFileName: Input file name
  • string $outFileName: Output file name
engineEncrypt (line 223)

Encrypt the passed $data, using current configurations for cipher, cipher mode and cipher key

string|bool engineEncrypt (string $data, [string $saveTo = ''])
  • string $data: Data to encrypt
  • string $saveTo: Optional file where encrypted data must be saved
engineEncryptFile (line 253)

Encrypts the contents of a file, saving the results in another file

bool engineEncryptFile (string $inFileName, string $outFileName)
  • string $inFileName: Input file name
  • string $outFileName: Output file name
getCipher (line 126)

Get current cipher

string getCipher ()
getCipherList (line 117)

Get all available cipher algorithms

array getCipherList ()
getCipherMode (line 160)

Get current cipher mode

string getCipherMode ()
getKey (line 183)

Get cipher key

string getKey ()
getModeList (line 151)

Get all available cipher modes

array getModeList ()
setCipher (line 136)

Set cipher algorithm

bool setCipher (string $cipher)
  • string $cipher: New cipher
setCipherMode (line 170)

Set cipher mode

bool setCipherMode (string $cipherMode)
  • string $cipherMode: New cipher mode
setKey (line 195)

Set cipher key

void setKey (string $key)
  • string $key
_initialize (line 341)

Initializes the cipher module before encrypting or decrypting data

bool _initialize ()

Inherited Methods

Inherited From PHP2Go

PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()

Documentation generated on Sun, 07 Oct 2007 19:21:54 -0300 by phpDocumentor 1.3.2