Last active
September 7, 2023 18:39
-
-
Save BARNZ/b82fb3bdc1f27d6633dd85b0e6ae9fef to your computer and use it in GitHub Desktop.
Generate a Laravel 5.x hash/token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Support\Facades\Password; | |
# Generate a token in the same style as laravels password reset tokens. | |
# Will generate something like: 785f616c4978a87ad65a899ed4133b358a4697649c55b0965a7ebb7486bd9801 | |
/** @var DatabaseTokenRepository */ | |
$repo = Password::getRepository(); | |
$token = $repo->createNewToken($user); | |
# Laravels underlying token generation technique for the above is: | |
# hash_hmac('sha256', Str::random(40), <your-app-key>) |
You can also obtain it for a user using
Password::broker()->createToken($user);
sorry if my questions seems weird but after creating this token how could i check which user dose it belong to ?!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also obtain it for a user using
Password::broker()->createToken($user);