Example #1
0
 /**
  * Default Constructor.
  *
  * Determines whether or not the mcrypt extension should be used.
  *
  * $mode could be:
  *
  * - CRYPT_DES_MODE_ECB
  *
  * - CRYPT_DES_MODE_CBC
  *
  * - CRYPT_DES_MODE_CTR
  *
  * - CRYPT_DES_MODE_CFB
  *
  * - CRYPT_DES_MODE_OFB
  *
  * - CRYPT_DES_MODE_3CBC
  *
  * If not explicitly set, CRYPT_DES_MODE_CBC will be used.
  *
  * @see Crypt_DES::Crypt_DES()
  * @see Crypt_Base::Crypt_Base()
  * @param optional Integer $mode
  * @access public
  */
 function Crypt_TripleDES($mode = CRYPT_DES_MODE_CBC)
 {
     switch ($mode) {
         // In case of CRYPT_DES_MODE_3CBC, we init as CRYPT_DES_MODE_CBC
         // and additional flag us internally as 3CBC
         case CRYPT_DES_MODE_3CBC:
             parent::Crypt_Base(CRYPT_DES_MODE_CBC);
             $this->mode_3cbc = true;
             // This three $des'es will do the 3CBC work (if $key > 64bits)
             $this->des = array(new Crypt_DES(CRYPT_DES_MODE_CBC), new Crypt_DES(CRYPT_DES_MODE_CBC), new Crypt_DES(CRYPT_DES_MODE_CBC));
             // we're going to be doing the padding, ourselves, so disable it in the Crypt_DES objects
             $this->des[0]->disablePadding();
             $this->des[1]->disablePadding();
             $this->des[2]->disablePadding();
             break;
             // If not 3CBC, we init as usual
         // If not 3CBC, we init as usual
         default:
             parent::Crypt_Base($mode);
     }
 }