How to update the admin user's password in your Magento website

We can easily change the admin password of a Magento site with the following code. Feel free to change how the password works as the below is too basic.

define('PATH_TO_MAGENTO', ''); require_once PATH_TO_MAGENTO.'app/Mage.php'; Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $characters = array( array('b', 'B'), array('c', 'C'), array('d', 'D'), array('f', 'F'), array('g', 'G'), array('h', 'H'), array('j', 'J'), array('k', 'K'), array('l', 'L'), array('m', 'M'), array('n', 'N'), array('p', 'P'), array('q', 'Q'), array('r', 'R'), array('s', 'S'), array('t', 'T'), array('v', 'V'), array('w', 'W'), array('x', 'X'), array('y', 'Y'), array('z', 'Z'), '1', '2', '3', '4', '5', '6', '7', '8', '9', ); shuffle($characters); $admins = $model->getCollection()->addFieldToFilter('password',''); foreach($admins as $admin) { $password = ''; $totalCharacters = count($characters); for ($i = 0; $i < $totalCharacters; $i++) { $character = array_pop($characters); if (is_array($character)) { $character = rand(0, 1) ? array_shift($character) : array_pop($character); } $password .= $character; } $admin->setPassword($password)->save(); }