Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Random string
  • Loading branch information
remdex committed Oct 5, 2021
1 parent 630598c commit 1b101a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
12 changes: 11 additions & 1 deletion lhc_web/lib/core/lhchat/lhchat.php
Expand Up @@ -1372,7 +1372,17 @@ public static function isChatActive($chat_id,$hash)

public static function generateHash()
{
return sha1(mt_rand().time());
$string = '';

while (($len = strlen($string)) < 40) {
$size = 40 - $len;

$bytes = random_bytes($size);

$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
}

return $string;;
}

public static function setTimeZoneByChat($chat)
Expand Down
12 changes: 11 additions & 1 deletion lhc_web/lib/core/lhchatbox/lhchatbox.php
Expand Up @@ -405,7 +405,17 @@ public static function getCount($params = array(), $table = 'lh_chatbox', $opera

public static function generateHash()
{
return sha1(mt_rand().time());
$string = '';

while (($len = strlen($string)) < 40) {
$size = 40 - $len;

$bytes = random_bytes($size);

$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
}

return $string;;
}

public static function getSession()
Expand Down
26 changes: 12 additions & 14 deletions lhc_web/lib/models/lhuser/erlhcoreclassmodelforgotpassword.php
Expand Up @@ -20,22 +20,20 @@ public function setState( array $properties )
}
}

public static function randomPassword($lenght = 10)
{
$allchar = "abcdefghijklmnopqrstuvwxyz1234567890";
$str = "" ;

mt_srand(( double) microtime() * 1000000);

for ($i = 0; $i<$lenght; $i++) {
$str .= substr($allchar, mt_rand(0, 36), 1);
public static function randomPassword($length = 10)
{
$string = '';

while (($len = strlen($string)) < $length) {
$size = $length - $len;

$bytes = random_bytes($size);

$string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size);
}

$str = substr(md5($str . microtime() . rand(1, 10000000)), 0, $lenght);

return $str ;
}
return $string;;
}

public static function setRemindHash($user_id, $hash) {

Expand Down

0 comments on commit 1b101a0

Please sign in to comment.