PL/Account PHP: Difference between revisions
Jump to navigation
Jump to search
ThePiotrek (talk | contribs) (Created page with "==Sprawdzanie konta serwera MTA== Ta funkcja PHP zwróci wartość true jeśli hasło będzie takie samo jak to z bazy danych <syntaxhighlight lang="lua"> function passwordMat...") |
ThePiotrek (talk | contribs) No edit summary |
||
| Line 32: | Line 32: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[en | [[en:Account PHP]] | ||
Latest revision as of 13:50, 4 October 2016
Sprawdzanie konta serwera MTA
Ta funkcja PHP zwróci wartość true jeśli hasło będzie takie samo jak to z bazy danych
function passwordMatch( $plain, $hash )
{
//-- Puste hasła nigdy nie pasują
if ( $plain == "" || $hash == "" )
return false;
if ( strlen($hash) == 64 + 32 + 1 )
{
//-- SHA256 + typ + sól
$strSha256 = substr( $hash, 0, 64 );
$strType = substr( $hash, 64, 1 );
$strSalt = substr( $hash, 65, 32 );
//-- Hash hasła został wygenerowany z użyciem MD5, więc zróbmy to samo dla testu
if ( $strType == "1" )
$plain = strtoupper(md5($plain));
$strPasswordHashed = strtoupper(hash( "sha256", $strSalt . $plain ));
return $strPasswordHashed == $strSha256;
}
else
if ( strlen($hash) == 32 )
{
//-- MD5
return strtoupper(md5($plain)) == $hash;
}
return false;
}