后台配置设置的时候有时候需要加密保存,如一些关键的账号密码就不应该明文保存到数据库和显示在前台。 配置代码如下面 后台Configuration encrypted 配置加密的代码
<app_secret translate="label"> <label>app_secret</label> <frontend_type>password</frontend_type> <backend_model>adminhtml/system_config_backend_encrypted</backend_model> <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </app_secret>
获取值得代码
appSecret = Mage::getStoreConfig('facebook_login/setting/app_secret',storeId);
直接拿getStoreConfig 获取到的值是经过加密的,还需要解密才能用。 解密代码
appSecret = Mage::helper('core')->decrypt(appSecret);
其他问题,配置文件中设置<frontend_type>password</frontend_type>的时候,前台还是能看到明文字符的。 要不显示明文字符,配置文件中设置<frontend_type>obscure</frontend_type>即可。