예제 #1
0
파일: Data.php 프로젝트: okite11/frames21
 /**
  * Get encryption singleton thing
  *
  * Not using core/cryption because it auto-base64 encodes stuff which we
  * don't want in this case
  *
  * @return Mage_Core_Model_Encryption
  */
 protected function _getCrypt()
 {
     if (is_null($this->_crypt)) {
         $this->_crypt = Varien_Crypt::factory()->init($this->_getCryptKey());
     }
     return $this->_crypt;
 }
 /**
  * Instantiate crypt model
  *
  * @param string $key
  * @return Varien_Crypt_Mcrypt
  */
 protected function _getCrypt($key = null)
 {
     if (!$this->_crypt) {
         if (null === $key) {
             $key = (string) Mage::getConfig()->getNode('global/crypt/key');
         }
         $this->_crypt = Varien_Crypt::factory()->init($key);
     }
     return $this->_crypt;
 }
예제 #3
0
 /**
  * Initialize crypt module if needed
  *
  * By default initializes with latest key and crypt versions
  *
  * @param string $key
  * @return Varien_Crypt_Mcrypt
  */
 protected function _getCrypt($key = null, $cipherVersion = null)
 {
     if (null === $key && null == $cipherVersion) {
         $cipherVersion = self::CIPHER_RIJNDAEL_256;
     }
     if (null === $key) {
         $key = $this->_keys[$this->_keyVersion];
     }
     if (null === $cipherVersion) {
         $cipherVersion = $this->_cipher;
     }
     $cipherVersion = $this->validateCipher($cipherVersion);
     $this->_crypts[$key][$cipherVersion] = Varien_Crypt::factory();
     $this->_crypts[$key][$cipherVersion]->setMode(MCRYPT_MODE_ECB);
     $this->_crypts[$key][$cipherVersion]->setCipher(MCRYPT_BLOWFISH);
     if ($cipherVersion === self::CIPHER_RIJNDAEL_128) {
         $this->_crypts[$key][$cipherVersion]->setCipher(MCRYPT_RIJNDAEL_128);
     } elseif ($cipherVersion === self::CIPHER_RIJNDAEL_256) {
         $this->_crypts[$key][$cipherVersion]->setCipher(MCRYPT_RIJNDAEL_128);
         $this->_crypts[$key][$cipherVersion]->setMode(MCRYPT_MODE_CBC);
         $this->_crypts[$key][$cipherVersion]->setInitVector($this->_iv);
     }
     $this->_crypts[$key][$cipherVersion]->init($key);
     return $this->_crypts[$key][$cipherVersion];
 }