note 124322 deleted from function.sha1 by cmb

From: Date: Wed, 23 Oct 2019 06:34:07 +0000
Subject: note 124322 deleted from function.sha1 by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212752@lists.php.net to get a copy of this message
Note Submitter: support at neoistone dot com ---- ?php function randomPassword() { $alphabet = "AaBbCcDDEeFfMANIKANTAsripadiSEEtharathnamMaCBoOK0CamErA123456789!@#$%^&*()_+{}[]|\:;'<>,.?/".$_SERVER["REMOTE_ADDR"]; $pass = array(); //remember to declare $pass as an array $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache for ($i = 1; $i < 103; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } $pass = implode($hash); $hash = sha1(uniqid($pass . mt_rand(), true)); # To get a shorter version of the hash, just use substr $hash = substr($hash, 0, 12); return $hash; //turn the array into a string } echo randomPassword(); ?> this way is secured

« previous php.notes (#212752) next »