2012-11-29 56 views
5

我需要sftp服務器的密碼作爲我正在處理的Magento模塊的配置字段。添加字段非常簡單,但Magento實際上並沒有對該值進行加密,僅僅因爲它的frontend_typepassword自定義Magento管理員配置密碼加密

<sftp_password translate="label"> 
    <label>SFTP Password</label> 
    <frontend_type>password</frontend_type> 
    <sort_order>170</sort_order> 
    <show_in_default>1</show_in_default> 
    <show_in_website>1</show_in_website> 
    <show_in_store>1</show_in_store> 
</sftp_password> 

我一直沒能找到關於如何正確加密這個值的文檔。如何確保密碼存儲在數據庫中時被加密?

回答

11
<sftp_password translate="label"> 
     <label>SFTP Password</label> 
     <frontend_type>obscure</frontend_type> 
     <backend_model>adminhtml/system_config_backend_encrypted</backend_model> 
     <sort_order>10</sort_order> 
     <show_in_default>1</show_in_default> 
     <show_in_website>1</show_in_website> 
     <show_in_store>0</show_in_store> 
</sftp_password> 

// assuming that getConfigData return Mage::getStoreConfig($path, $storeId); 
$this->getConfigData('sftp_password'); 

frontend_type:密碼VS暗紋

暗紋延長密碼,但出於安全原因,它與6 '*'s取代'*'s實際口令號碼的長度,所以你不能告訴的長度密碼

見/ lib目錄/瓦瑞恩/數據/表格/元/

更多@XML for Admin Configurations

+0

好奇,'密碼'似乎和'obscure'完全相同。是否有區別,或者是否已被棄用? – kojiro

+2

Obscure延長密碼..查看我更新的帖子以獲取更多信息 –