Skip to content

Instantly share code, notes, and snippets.

@ivanvermeyen
Created February 20, 2017 14:44
Show Gist options
  • Save ivanvermeyen/872061aa4134d9b8f6b6c18d28ef9472 to your computer and use it in GitHub Desktop.
Save ivanvermeyen/872061aa4134d9b8f6b6c18d28ef9472 to your computer and use it in GitHub Desktop.
<?php
/**
* Generate a secure token.
*
* @url http://stackoverflow.com/questions/18910814/best-practice-to-generate-random-token-for-forgot-password
*/
function generateToken($length = 40)
{
return bin2hex(random_bytes($length));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment