Skip to content

Instantly share code, notes, and snippets.

@rseon
Last active August 27, 2018 14:52
Show Gist options
  • Save rseon/523f6aa6af9598454b6a0a6fc4e3fb20 to your computer and use it in GitHub Desktop.
Save rseon/523f6aa6af9598454b6a0a6fc4e3fb20 to your computer and use it in GitHub Desktop.
[PHP] Random token
<?php
/**
* Génère une chaine aléatoire de $ln caractères.
*
* @param int $ln
* @return string
*/
function getToken($ln = 8) {
return bin2hex(openssl_random_pseudo_bytes((int) $ln / 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment