我不是100%肯定(这是一个快速grep
),但我认为密码加密发生在
File: app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Encrypted.php
protected function _beforeSave()
{
$value = (string)$this->getValue();
// don't change value, if an obscured value came
if (preg_match('/^\*+$/', $this->getValue())) {
$value = $this->getOldValue();
}
if (!empty($value) && ($encrypted = Mage::helper('core')->encrypt($value))) {
$this->setValue($encrypted);
}
}
请记住,这是一个加密,不散列。由于您要存储密码以便在某个地方使用(最常见的是支付API),因此Magento需要能够解密已被炒作的内容。因此,您可以使用核心帮助程序的encrypt
方法生成这些值。你也可以尝试这样的事情
$o = Mage::getModel('adminhtml/system_config_backend_encrypted');
$o->setData('value','encrypted or unencrypted value');
$o->beforeSave(); //to encrypt the value
$o->afterLoad(); //to unencrypted the value
$password = $o->getValue(); //fetch the value
只要记住,每个店铺都有自己的加密密钥,所以这不会是分发模块非常有用。
您还应该在3210加载和处理中查看backend_model
属性(自我链接免责声明,未在互联网上的任何其他地方记录)。
希望有所帮助。
TIL有一个_afterLoad的公共包装器...不幸的是不是_beforeSave的情况,虽然:) –