Esempio n. 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 explictly set, CRYPT_DES_MODE_CBC will be used.
  *
  * @see DES::DES()
  * @see Base::Base()
  * @param optional Integer $mode
  * @access public
  */
 function 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::DES(CRYPT_DES_MODE_CBC);
             $this->mode_3cbc = true;
             // This three $des'es will do the 3CBC work (if $key > 64bits)
             $this->des = array(new DES(CRYPT_DES_MODE_CBC), new DES(CRYPT_DES_MODE_CBC), new DES(CRYPT_DES_MODE_CBC));
             // we're going to be doing the padding, ourselves, so disable it in the 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::DES($mode);
     }
 }