mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
improve error handling for salt generation
This commit is contained in:
parent
a7f03d101c
commit
a54d40f2a2
1 changed files with 11 additions and 5 deletions
|
|
@ -124,17 +124,23 @@
|
||||||
unset($sCheckName, $sCheckFilePath, $sCheckFolder, $sTest);
|
unset($sCheckName, $sCheckFilePath, $sCheckFolder, $sTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === $sSalt)
|
if (false === $sSalt) {
|
||||||
{
|
|
||||||
if (function_exists('random_bytes'))
|
if (function_exists('random_bytes'))
|
||||||
{ // secure random salt
|
{ // secure random salt
|
||||||
|
try
|
||||||
|
{
|
||||||
$sSalt = bin2hex(random_bytes(48));
|
$sSalt = bin2hex(random_bytes(48));
|
||||||
}
|
}
|
||||||
elseif (function_exists('openssl_random_pseudo_bytes'))
|
catch (\Exception $oException)
|
||||||
|
{
|
||||||
|
$sSalt = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((false === $sSalt) && (function_exists('openssl_random_pseudo_bytes')))
|
||||||
{ // not-quite as secure random salt
|
{ // not-quite as secure random salt
|
||||||
$sSalt = bin2hex(openssl_random_pseudo_bytes(48));
|
$sSalt = bin2hex(openssl_random_pseudo_bytes(48));
|
||||||
}
|
}
|
||||||
else
|
if (false === $sSalt)
|
||||||
{ // pseudo-random salt
|
{ // pseudo-random salt
|
||||||
$sSalt = md5(microtime(true).rand(1000, 5000))
|
$sSalt = md5(microtime(true).rand(1000, 5000))
|
||||||
.md5(microtime(true).rand(5000, 9999))
|
.md5(microtime(true).rand(5000, 9999))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue