How to generate random password for customer in Magento2?How to generate random password for new customer while creating account in magento?password error after upgrade to 1.9.1Magento 2.1 - Set customer password in backendBest Way to Load a Custom Model in Magento 2Remove fields from registration formMagento 2 : How to update customer password by customer repositoryForm is not displayed on panel admin Magento 2How to generate random password for new customer while creating account in magento 2?Magento 2 How to disable price from orders, customer account and order view if custom module is enabled?
Is it feasible to get a hash collision for CRC32, MD-5 and SHA-1 on one file?
how do companies get money from being listed publicly
What is a good class if we remove subclasses?
The cat ate your input again!
How to remove ambiguity: "... lives in the city of H, the capital of the province of NS, WHERE the unemployment rate is ..."?
Not going forward with internship interview process
Is it legal for a company to enter an agreement not to hire employees from another company?
How to divide item stack in MC PE?
How does proof assistant organize knowledge?
How are you supposed to know the strumming pattern for a song from the "chord sheet music"?
Is God unknowable?
Is this n-speak?
Is there a command to install basic applications on Ubuntu 16.04?
Submitting a new paper just after another was accepted by the same journal
Is this curved text blend possible in Illustrator?
When were the tantalum capacitors first used in computing?
Plotting octahedron inside the sphere and sphere inside the cube
Is there a standardised way to check fake news?
A continuous water "planet" ring around a star
How would timezones work on a planet 100 times the size of our Earth
Why is the result of ('b'+'a'+ + 'a' + 'a').toLowerCase() 'banana'?
Loading military units into ships optimally, using backtracking
Solution to German Tank Problem
On the Rømer experiments and the speed of light
How to generate random password for customer in Magento2?
How to generate random password for new customer while creating account in magento?password error after upgrade to 1.9.1Magento 2.1 - Set customer password in backendBest Way to Load a Custom Model in Magento 2Remove fields from registration formMagento 2 : How to update customer password by customer repositoryForm is not displayed on panel admin Magento 2How to generate random password for new customer while creating account in magento 2?Magento 2 How to disable price from orders, customer account and order view if custom module is enabled?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
We had a method to generate the random passwords for the customers in Magento1 in following class.
appcodecoreMageCustomerModelCustomer.php
method >>
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 8)
$chars = Mage_Core_Helper_Data::CHARS_PASSWORD_LOWERS
. Mage_Core_Helper_Data::CHARS_PASSWORD_UPPERS
. Mage_Core_Helper_Data::CHARS_PASSWORD_DIGITS
. Mage_Core_Helper_Data::CHARS_PASSWORD_SPECIALS;
return Mage::helper('core')->getRandomString($length, $chars);
What is the similar method in Magento2?
magento-2.1 customer password
add a comment |
We had a method to generate the random passwords for the customers in Magento1 in following class.
appcodecoreMageCustomerModelCustomer.php
method >>
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 8)
$chars = Mage_Core_Helper_Data::CHARS_PASSWORD_LOWERS
. Mage_Core_Helper_Data::CHARS_PASSWORD_UPPERS
. Mage_Core_Helper_Data::CHARS_PASSWORD_DIGITS
. Mage_Core_Helper_Data::CHARS_PASSWORD_SPECIALS;
return Mage::helper('core')->getRandomString($length, $chars);
What is the similar method in Magento2?
magento-2.1 customer password
add a comment |
We had a method to generate the random passwords for the customers in Magento1 in following class.
appcodecoreMageCustomerModelCustomer.php
method >>
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 8)
$chars = Mage_Core_Helper_Data::CHARS_PASSWORD_LOWERS
. Mage_Core_Helper_Data::CHARS_PASSWORD_UPPERS
. Mage_Core_Helper_Data::CHARS_PASSWORD_DIGITS
. Mage_Core_Helper_Data::CHARS_PASSWORD_SPECIALS;
return Mage::helper('core')->getRandomString($length, $chars);
What is the similar method in Magento2?
magento-2.1 customer password
We had a method to generate the random passwords for the customers in Magento1 in following class.
appcodecoreMageCustomerModelCustomer.php
method >>
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 8)
$chars = Mage_Core_Helper_Data::CHARS_PASSWORD_LOWERS
. Mage_Core_Helper_Data::CHARS_PASSWORD_UPPERS
. Mage_Core_Helper_Data::CHARS_PASSWORD_DIGITS
. Mage_Core_Helper_Data::CHARS_PASSWORD_SPECIALS;
return Mage::helper('core')->getRandomString($length, $chars);
What is the similar method in Magento2?
magento-2.1 customer password
magento-2.1 customer password
edited Aug 1 at 10:22
Mohit Rane
1,20718 bronze badges
1,20718 bronze badges
asked Jul 25 '17 at 8:53
MukeshMukesh
9551 gold badge15 silver badges45 bronze badges
9551 gold badge15 silver badges45 bronze badges
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
I used the following code to generate the passwords for the customers.
<?php
namespace MukCommonHelper;
class CustomerPasswordGeneration extends MagentoFrameworkAppHelperAbstractHelper
{
/**
* @var MagentoFrameworkMathRandom
*/
protected $mathRandom;
public function __construct(
Context $context,
MagentoFrameworkMathRandom $mathRandom
)
$this->mathRandom = $mathRandom;
parent::__construct($context);
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 10)
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
return $password = $this->mathRandom->getRandomString($length, $chars);
add a comment |
Magento use function like this in the setup script
vendor/magento/magento2-base/setup/src/Magento/Setup/Model/AdminAccount.php
/**
* Generate password string
*
* @return string
*/
protected function generatePassword()
return $this->encryptor->getHash($this->data[self::KEY_PASSWORD], true);
1
I know about this. But in my case I am not passing self::KEY_PASSWORD to generate the password.
– Mukesh
Jul 25 '17 at 9:04
1
also check Magento/Customer/Model/AccountManagement.php I think you have to generate password string by your own if you have not it
– bxN5
Jul 25 '17 at 9:13
yes, for random strings I can use class MagentoFrameworkMathRandom
– Mukesh
Jul 25 '17 at 11:10
add a comment |
I have made one custom url (new custom controller) to generate customer's password .
<?php
namespace CompanyModuleControllerIndex;
use MagentoFrameworkEncryptionEncryptorInterface as Encryptor;
class Index extends MagentoFrameworkAppActionAction
protected $_resultPageFactory;
protected $_indexer;
public function __construct(MagentoFrameworkAppActionContext $context,Encryptor $encryptor, MagentoFrameworkViewResultPageFactory $resultPageFactory)
$this->_resultPageFactory = $resultPageFactory;
$this->encryptor = $encryptor;
return parent::__construct($context);
public function execute()
$password = '123456'; //or you can use php random function rand() to generate string
$hash = $this->encryptor->hash($password);
$newhash = $this->encryptor->getHash($password, true);
echo $newhash; // this will be customer's new password, which need to store in 'password_hash' column of "customer_entity" db table.
you can integrate same code in your functional method / file .
add a comment |
I used this code simply and got result
<?php
function generateRandomString($length)
$characters =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%&';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++)
$randomString .= $characters[rand(0, $charactersLength - 1)];
return $randomString;
?>
<?php echo generateRandomString(5); ?>
add a comment |
I used the following method
<?php
function randomPassword()
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$password = [];
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++)
$n = rand(0, $alphaLength);
$password[] = $alphabet[$n];
return implode($password);
randomPassword();
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f186309%2fhow-to-generate-random-password-for-customer-in-magento2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
I used the following code to generate the passwords for the customers.
<?php
namespace MukCommonHelper;
class CustomerPasswordGeneration extends MagentoFrameworkAppHelperAbstractHelper
{
/**
* @var MagentoFrameworkMathRandom
*/
protected $mathRandom;
public function __construct(
Context $context,
MagentoFrameworkMathRandom $mathRandom
)
$this->mathRandom = $mathRandom;
parent::__construct($context);
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 10)
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
return $password = $this->mathRandom->getRandomString($length, $chars);
add a comment |
I used the following code to generate the passwords for the customers.
<?php
namespace MukCommonHelper;
class CustomerPasswordGeneration extends MagentoFrameworkAppHelperAbstractHelper
{
/**
* @var MagentoFrameworkMathRandom
*/
protected $mathRandom;
public function __construct(
Context $context,
MagentoFrameworkMathRandom $mathRandom
)
$this->mathRandom = $mathRandom;
parent::__construct($context);
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 10)
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
return $password = $this->mathRandom->getRandomString($length, $chars);
add a comment |
I used the following code to generate the passwords for the customers.
<?php
namespace MukCommonHelper;
class CustomerPasswordGeneration extends MagentoFrameworkAppHelperAbstractHelper
{
/**
* @var MagentoFrameworkMathRandom
*/
protected $mathRandom;
public function __construct(
Context $context,
MagentoFrameworkMathRandom $mathRandom
)
$this->mathRandom = $mathRandom;
parent::__construct($context);
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 10)
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
return $password = $this->mathRandom->getRandomString($length, $chars);
I used the following code to generate the passwords for the customers.
<?php
namespace MukCommonHelper;
class CustomerPasswordGeneration extends MagentoFrameworkAppHelperAbstractHelper
{
/**
* @var MagentoFrameworkMathRandom
*/
protected $mathRandom;
public function __construct(
Context $context,
MagentoFrameworkMathRandom $mathRandom
)
$this->mathRandom = $mathRandom;
parent::__construct($context);
/**
* Retrieve random password
*
* @param int $length
* @return string
*/
public function generatePassword($length = 10)
$chars = MagentoFrameworkMathRandom::CHARS_LOWERS
. MagentoFrameworkMathRandom::CHARS_UPPERS
. MagentoFrameworkMathRandom::CHARS_DIGITS;
return $password = $this->mathRandom->getRandomString($length, $chars);
answered Jul 26 '17 at 5:39
MukeshMukesh
9551 gold badge15 silver badges45 bronze badges
9551 gold badge15 silver badges45 bronze badges
add a comment |
add a comment |
Magento use function like this in the setup script
vendor/magento/magento2-base/setup/src/Magento/Setup/Model/AdminAccount.php
/**
* Generate password string
*
* @return string
*/
protected function generatePassword()
return $this->encryptor->getHash($this->data[self::KEY_PASSWORD], true);
1
I know about this. But in my case I am not passing self::KEY_PASSWORD to generate the password.
– Mukesh
Jul 25 '17 at 9:04
1
also check Magento/Customer/Model/AccountManagement.php I think you have to generate password string by your own if you have not it
– bxN5
Jul 25 '17 at 9:13
yes, for random strings I can use class MagentoFrameworkMathRandom
– Mukesh
Jul 25 '17 at 11:10
add a comment |
Magento use function like this in the setup script
vendor/magento/magento2-base/setup/src/Magento/Setup/Model/AdminAccount.php
/**
* Generate password string
*
* @return string
*/
protected function generatePassword()
return $this->encryptor->getHash($this->data[self::KEY_PASSWORD], true);
1
I know about this. But in my case I am not passing self::KEY_PASSWORD to generate the password.
– Mukesh
Jul 25 '17 at 9:04
1
also check Magento/Customer/Model/AccountManagement.php I think you have to generate password string by your own if you have not it
– bxN5
Jul 25 '17 at 9:13
yes, for random strings I can use class MagentoFrameworkMathRandom
– Mukesh
Jul 25 '17 at 11:10
add a comment |
Magento use function like this in the setup script
vendor/magento/magento2-base/setup/src/Magento/Setup/Model/AdminAccount.php
/**
* Generate password string
*
* @return string
*/
protected function generatePassword()
return $this->encryptor->getHash($this->data[self::KEY_PASSWORD], true);
Magento use function like this in the setup script
vendor/magento/magento2-base/setup/src/Magento/Setup/Model/AdminAccount.php
/**
* Generate password string
*
* @return string
*/
protected function generatePassword()
return $this->encryptor->getHash($this->data[self::KEY_PASSWORD], true);
answered Jul 25 '17 at 9:00
bxN5bxN5
1663 bronze badges
1663 bronze badges
1
I know about this. But in my case I am not passing self::KEY_PASSWORD to generate the password.
– Mukesh
Jul 25 '17 at 9:04
1
also check Magento/Customer/Model/AccountManagement.php I think you have to generate password string by your own if you have not it
– bxN5
Jul 25 '17 at 9:13
yes, for random strings I can use class MagentoFrameworkMathRandom
– Mukesh
Jul 25 '17 at 11:10
add a comment |
1
I know about this. But in my case I am not passing self::KEY_PASSWORD to generate the password.
– Mukesh
Jul 25 '17 at 9:04
1
also check Magento/Customer/Model/AccountManagement.php I think you have to generate password string by your own if you have not it
– bxN5
Jul 25 '17 at 9:13
yes, for random strings I can use class MagentoFrameworkMathRandom
– Mukesh
Jul 25 '17 at 11:10
1
1
I know about this. But in my case I am not passing self::KEY_PASSWORD to generate the password.
– Mukesh
Jul 25 '17 at 9:04
I know about this. But in my case I am not passing self::KEY_PASSWORD to generate the password.
– Mukesh
Jul 25 '17 at 9:04
1
1
also check Magento/Customer/Model/AccountManagement.php I think you have to generate password string by your own if you have not it
– bxN5
Jul 25 '17 at 9:13
also check Magento/Customer/Model/AccountManagement.php I think you have to generate password string by your own if you have not it
– bxN5
Jul 25 '17 at 9:13
yes, for random strings I can use class MagentoFrameworkMathRandom
– Mukesh
Jul 25 '17 at 11:10
yes, for random strings I can use class MagentoFrameworkMathRandom
– Mukesh
Jul 25 '17 at 11:10
add a comment |
I have made one custom url (new custom controller) to generate customer's password .
<?php
namespace CompanyModuleControllerIndex;
use MagentoFrameworkEncryptionEncryptorInterface as Encryptor;
class Index extends MagentoFrameworkAppActionAction
protected $_resultPageFactory;
protected $_indexer;
public function __construct(MagentoFrameworkAppActionContext $context,Encryptor $encryptor, MagentoFrameworkViewResultPageFactory $resultPageFactory)
$this->_resultPageFactory = $resultPageFactory;
$this->encryptor = $encryptor;
return parent::__construct($context);
public function execute()
$password = '123456'; //or you can use php random function rand() to generate string
$hash = $this->encryptor->hash($password);
$newhash = $this->encryptor->getHash($password, true);
echo $newhash; // this will be customer's new password, which need to store in 'password_hash' column of "customer_entity" db table.
you can integrate same code in your functional method / file .
add a comment |
I have made one custom url (new custom controller) to generate customer's password .
<?php
namespace CompanyModuleControllerIndex;
use MagentoFrameworkEncryptionEncryptorInterface as Encryptor;
class Index extends MagentoFrameworkAppActionAction
protected $_resultPageFactory;
protected $_indexer;
public function __construct(MagentoFrameworkAppActionContext $context,Encryptor $encryptor, MagentoFrameworkViewResultPageFactory $resultPageFactory)
$this->_resultPageFactory = $resultPageFactory;
$this->encryptor = $encryptor;
return parent::__construct($context);
public function execute()
$password = '123456'; //or you can use php random function rand() to generate string
$hash = $this->encryptor->hash($password);
$newhash = $this->encryptor->getHash($password, true);
echo $newhash; // this will be customer's new password, which need to store in 'password_hash' column of "customer_entity" db table.
you can integrate same code in your functional method / file .
add a comment |
I have made one custom url (new custom controller) to generate customer's password .
<?php
namespace CompanyModuleControllerIndex;
use MagentoFrameworkEncryptionEncryptorInterface as Encryptor;
class Index extends MagentoFrameworkAppActionAction
protected $_resultPageFactory;
protected $_indexer;
public function __construct(MagentoFrameworkAppActionContext $context,Encryptor $encryptor, MagentoFrameworkViewResultPageFactory $resultPageFactory)
$this->_resultPageFactory = $resultPageFactory;
$this->encryptor = $encryptor;
return parent::__construct($context);
public function execute()
$password = '123456'; //or you can use php random function rand() to generate string
$hash = $this->encryptor->hash($password);
$newhash = $this->encryptor->getHash($password, true);
echo $newhash; // this will be customer's new password, which need to store in 'password_hash' column of "customer_entity" db table.
you can integrate same code in your functional method / file .
I have made one custom url (new custom controller) to generate customer's password .
<?php
namespace CompanyModuleControllerIndex;
use MagentoFrameworkEncryptionEncryptorInterface as Encryptor;
class Index extends MagentoFrameworkAppActionAction
protected $_resultPageFactory;
protected $_indexer;
public function __construct(MagentoFrameworkAppActionContext $context,Encryptor $encryptor, MagentoFrameworkViewResultPageFactory $resultPageFactory)
$this->_resultPageFactory = $resultPageFactory;
$this->encryptor = $encryptor;
return parent::__construct($context);
public function execute()
$password = '123456'; //or you can use php random function rand() to generate string
$hash = $this->encryptor->hash($password);
$newhash = $this->encryptor->getHash($password, true);
echo $newhash; // this will be customer's new password, which need to store in 'password_hash' column of "customer_entity" db table.
you can integrate same code in your functional method / file .
edited Jul 25 '17 at 10:17
simple guy
1,0492 gold badges15 silver badges43 bronze badges
1,0492 gold badges15 silver badges43 bronze badges
answered Jul 25 '17 at 9:27
LuckyLucky
1221 silver badge10 bronze badges
1221 silver badge10 bronze badges
add a comment |
add a comment |
I used this code simply and got result
<?php
function generateRandomString($length)
$characters =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%&';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++)
$randomString .= $characters[rand(0, $charactersLength - 1)];
return $randomString;
?>
<?php echo generateRandomString(5); ?>
add a comment |
I used this code simply and got result
<?php
function generateRandomString($length)
$characters =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%&';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++)
$randomString .= $characters[rand(0, $charactersLength - 1)];
return $randomString;
?>
<?php echo generateRandomString(5); ?>
add a comment |
I used this code simply and got result
<?php
function generateRandomString($length)
$characters =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%&';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++)
$randomString .= $characters[rand(0, $charactersLength - 1)];
return $randomString;
?>
<?php echo generateRandomString(5); ?>
I used this code simply and got result
<?php
function generateRandomString($length)
$characters =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@#$%&';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++)
$randomString .= $characters[rand(0, $charactersLength - 1)];
return $randomString;
?>
<?php echo generateRandomString(5); ?>
answered Aug 2 '18 at 9:51
SUBBULAKSHMI GSUBBULAKSHMI G
809 bronze badges
809 bronze badges
add a comment |
add a comment |
I used the following method
<?php
function randomPassword()
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$password = [];
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++)
$n = rand(0, $alphaLength);
$password[] = $alphabet[$n];
return implode($password);
randomPassword();
add a comment |
I used the following method
<?php
function randomPassword()
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$password = [];
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++)
$n = rand(0, $alphaLength);
$password[] = $alphabet[$n];
return implode($password);
randomPassword();
add a comment |
I used the following method
<?php
function randomPassword()
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$password = [];
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++)
$n = rand(0, $alphaLength);
$password[] = $alphabet[$n];
return implode($password);
randomPassword();
I used the following method
<?php
function randomPassword()
$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
$password = [];
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++)
$n = rand(0, $alphaLength);
$password[] = $alphabet[$n];
return implode($password);
randomPassword();
edited Aug 5 at 6:43
answered Aug 1 at 10:00
Arshad SyedArshad Syed
488 bronze badges
488 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f186309%2fhow-to-generate-random-password-for-customer-in-magento2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown