Last active
August 27, 2018 14:52
-
-
Save rseon/523f6aa6af9598454b6a0a6fc4e3fb20 to your computer and use it in GitHub Desktop.
[PHP] Random 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 | |
/** | |
* 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