System.Security
[ class tree: System.Security ] [ index: System.Security ] [ all elements ]

Class: TDESCrypto

Source Location: /Security/TDESCrypto.php

Class Overview


TDESCrypto class

Class Details

[line 44]
TDESCrypto class

TDESCrypto is an implementation of DES (the Data Encryption Standard), an encryption algorithm which works on bits. It supports Electronic Codebook (ECB) and Cipher Block Chaining (CBC) and also includes Triple DES.

Example:

  1. $key="this is a 24 byte key !!";
  2. $message="this is a test message!";
  3. $des=new TDESCrypto;
  4. $ciphertext=$des->encrypt($message,$key);
  5. echo "DES Test Encrypted: " . $ciphertext;
  6. $recovered_message = $des->decrypt($ciphertext,$key);
  7. echo "\nDES Test Decrypted: " . $recovered_message;




[ Top ]

Methods



Class Methods


method decrypt [line 68]

string &decrypt( string &$data, string $key)

Decrypt data with DES (or 3DES if the key is at least 24 byte long).

Note, the key must be at least 8 byte long, or an exception will be raised.




return:  decrypted result
access:  public


Parameters:

string   &$data   data to be decrypted
string   $key   key

[ Top ]

method des [line 85]

string des( string $key, string $message, boolean $encrypt, integer $mode, string $iv)

The actual DES implementation.



return:  encryption/decryption result
access:  protected


Parameters:

string   $key   key
string   $message   data
boolean   $encrypt   true for encryption, false for decryption
integer   $mode   optional, 0 for ECB and 1 for CBC, ECB is the default
string   $iv   optional, 8 character string input vector (not used in ECB mode)

[ Top ]

method encrypt [line 53]

string &encrypt( string &$data, string $key)

Encrypt data with DES (or 3DES if the key is at least 24 byte long).

Note, the key must be at least 8 byte long, or an exception will be raised.




return:  encrypted result
access:  public


Parameters:

string   &$data   data to be encrypted
string   $key   key

[ Top ]


© 2004-2005 PRADO Software Group. All Rights Reserved.