Skip to content

Instantly share code, notes, and snippets.

@gaodeng
Forked from BARNZ/GenerateToken.php
Created May 17, 2019 14:13
Show Gist options
  • Select an option

  • Save gaodeng/cf71600c51d859e25fee1b70ed654a68 to your computer and use it in GitHub Desktop.

Select an option

Save gaodeng/cf71600c51d859e25fee1b70ed654a68 to your computer and use it in GitHub Desktop.
Generate a Laravel 5.x hash/token
<?php
use Illuminate\Support\Facades\Password;
# Generate a token in the same style as laravels password reset tokens.
# Will generate something like: 785f616c4978a87ad65a899ed4133b358a4697649c55b0965a7ebb7486bd9801
$token = Password::getRepository()->createNewToken();
# Laravels underlying token generation technique for the above is:
# hash_hmac('sha256', Str::random(40), <your-app-key>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment