/** * Decode data * * @param Mage_Core_Model_Abstract $object * @param string $filedName * @return mixed */ public function decode(Mage_Core_Model_Abstract $object, $filedName) { $value = $object->getData($filedName); if ($this->_shouldBeEncrypted($object, $filedName)) { $value = $this->_encryptor->decrypt($value); } return $value; }
public function testEncryptDecrypt() { $initial = md5(uniqid()); $encrypted = $this->_helper->encrypt($initial); $this->assertNotEquals($initial, $encrypted); $this->assertEquals($initial, $this->_helper->decrypt($encrypted)); }
/** * Return config values that may vary by website/store for the given * website. * @param Mage_Core_Model_Website $website * @return array Config values for store id, AMQP username and AMQP password */ public function getWebsiteLevelAmqpConfigurations(Mage_Core_Model_Website $website) { $storeIdPath = $this->_coreConfigMap->getPathForKey(self::STORE_ID_CONFIG_KEY); $usernamePath = $this->_amqpConfigMap->getPathForKey(self::USERNAME_CONFIG_KEY); $passwordPath = $this->_amqpConfigMap->getPathForKey(self::PASSWORD_CONFIG_KEY); $defaultCoreConfig = $this->_coreHelper->getConfigModel(Mage::app()->getStore(0)); $defaultAmqpConfig = $this->_helper->getConfigModel(Mage::app()->getStore(0)); // get website level config values, falling back to any not available to the // website with default store config values return array('store_id' => $website->getConfig($storeIdPath) ?: $defaultCoreConfig->storeId, 'username' => $website->getConfig($usernamePath) ?: $defaultAmqpConfig->username, 'password' => $this->_mageHelper->decrypt($website->getConfig($passwordPath)) ?: $defaultAmqpConfig->password); }