Skip to content

Instantly share code, notes, and snippets.

@rifki
Last active July 15, 2017 13:17
Show Gist options
  • Save rifki/6fca4757c5d62b70e107920cebf99693 to your computer and use it in GitHub Desktop.
Save rifki/6fca4757c5d62b70e107920cebf99693 to your computer and use it in GitHub Desktop.
magento 1.9.x: create customer password manually
<?php
// salt random string
// see formula: app/code/core/Mage/Core/Helper/Data.php method getRandomString
function salt($len = 32) {
$chars_lowers = 'abcdefghijklmnopqrstuvwxyz';
$chars_uppers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charts_digits = '0123456789';
$chars = $chars_lowers . $chars_uppers . $charts_digits;
for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) {
$str .= $chars[mt_rand(0, $lc)];
}
return $str;
}
$password = 'topsecret';
$salt = salt();
$resultPassword = md5($salt . $password) . ':' . $salt;
// dump password
var_dump($resultPassword);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment