-
Notifications
You must be signed in to change notification settings - Fork 3
Hash Class Documentation
Benyamin Khalife edited this page Jun 29, 2023
·
1 revision
The Hash
class provides methods for hashing and checking passwords using different hashing algorithms. This class is part of the Webrium
namespace.
This method hashes a text using the given algorithm.
-
$text
(string): The text to be hashed. -
$algorithm
(int) [optional]: The hashing algorithm to be used. Defaults toPASSWORD_DEFAULT
.
- Returns a string representing the hashed text.
$text = "password123";
$hashedText = Hash::make($text);
echo $hashedText;
// Output: $2y$10$HwMdWrmiz9c8Z3eu/lxU8Oop3GTwHPceYnJJC1eohKf6UcH5z/YpW
This method checks if a password matches a certain hash.
-
$password
(string): The password to be checked. -
$hash
(string): The hash to be compared against.
- Returns
true
if the password matches the hash,false
otherwise.
$password = "password123";
$hash = "$2y$10$HwMdWrmiz9c8Z3eu/lxU8Oop3GTwHPceYnJJC1eohKf6UcH5z/YpW";
if (Hash::check($password, $hash)) {
echo "Password is correct.";
} else {
echo "Password is incorrect.";
}
// Output: Password is correct.
I hope this helps! Let me know if you have any further questions.