no

Learn to Encrypt Customer Password in Magento

Unfortunately, since we have to integrate our another customized system x in magento, we have to find a way to sync it's users and passw...

Unfortunately, since we have to integrate our another customized system x in magento, we have to find a way to sync it's users and passwords fields.

Which we have achieved by:

Assumption:
1.) You must have a deployed magento system which you can access (because magento's libraries will be use in this solution). Specifically, core/encryption and core/helper/data.

To call the magento api in another system, paste the following lines:

require_once 'app/Mage.php'; //change the directory accordingly :D
umask(0);
$app = Mage::app('default');


And add more lines:

$obj = Mage::getModel('core/encryption'); //instantiate the core encryption mode,
$helper = Mage::helper('core'); //instantiate the core helper,
$obj->setHelper($helper); //set the encryptions helper,
$enc_pwd = $obj->getHash($pwd, 2); //get the password's hash


BTW, for info, you can check if you have entered a correct password by adding this line:

echo $obj->validateHash($pwd, $enc_pwd);


If it echoes 1 then the password is correct. Try it, it works for me.

Related

web-platform 6315005105038019078

Post a Comment Default Comments

6 comments

bill.cornell said...

Very helpful - thanks! I was trying to figure out how to do this and your code was exactly what I was looking for.

Filipe said...

Very nice!
Thanks!

U help a brazilian guy!

Anonymous said...

Lovely Article....Perfect...
Thanks Dear

Martin said...

Thank you very much. I used this code-snippet to realize a customer-import extension.

viettq said...

Thank you, very helpful!

Chamath said...

Thanks. It works fine for me.

item