Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

There's two sides to this review:

Security & Style.


##Style:

Style:

  • Directly return $hash instead of assigning it.
  • The string concatenation can be improved

into:

public static function makeSafe($password)
{
 $salt = "mySalt";
 return hash("sha256", "{$salt}.{$password}");
}

##Security:

Security:

When using a fixed salt, if they managed to break the compilation of the code and retrieve the plaintext salt, it would render the encrypted password down to a matching of common hashes.

Use a different salt for each user (make a random integer, more than 10 digits even), and store the salt beside the password inside the database.

There's two sides to this review:

Security & Style.


##Style:

  • Directly return $hash instead of assigning it.
  • The string concatenation can be improved

into:

public static function makeSafe($password)
{
 $salt = "mySalt";
 return hash("sha256", "{$salt}.{$password}");
}

##Security:

When using a fixed salt, if they managed to break the compilation of the code and retrieve the plaintext salt, it would render the encrypted password down to a matching of common hashes.

Use a different salt for each user (make a random integer, more than 10 digits even), and store the salt beside the password inside the database.

There's two sides to this review:

Security & Style.


Style:

  • Directly return $hash instead of assigning it.
  • The string concatenation can be improved

into:

public static function makeSafe($password)
{
 $salt = "mySalt";
 return hash("sha256", "{$salt}.{$password}");
}

Security:

When using a fixed salt, if they managed to break the compilation of the code and retrieve the plaintext salt, it would render the encrypted password down to a matching of common hashes.

Use a different salt for each user (make a random integer, more than 10 digits even), and store the salt beside the password inside the database.

Source Link
Quill
  • 12k
  • 5
  • 41
  • 93

There's two sides to this review:

Security & Style.


##Style:

  • Directly return $hash instead of assigning it.
  • The string concatenation can be improved

into:

public static function makeSafe($password)
{
 $salt = "mySalt";
 return hash("sha256", "{$salt}.{$password}");
}

##Security:

When using a fixed salt, if they managed to break the compilation of the code and retrieve the plaintext salt, it would render the encrypted password down to a matching of common hashes.

Use a different salt for each user (make a random integer, more than 10 digits even), and store the salt beside the password inside the database.

lang-php

AltStyle によって変換されたページ (->オリジナル) /