1
0
This repository has been archived on 2021-02-16. You can view files and clone it, but cannot push or open issues or pull requests.
Files
ttv-streamkit/bootstrap/helpers.php
2020-04-29 23:58:18 +02:00

21 lines
552 B
PHP

<?php
/**
* Create cryptographically secure tokens of custom length
*
* @author Scott https://stackoverflow.com/questions/1846202/php-how-to-generate-a-random-unique-alphanumeric-string/13733588#13733588
*/
function getToken($length){
$token = "";
$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";
$codeAlphabet.= "0123456789";
$max = strlen($codeAlphabet);
for ($i=0; $i < $length; $i++) {
$token .= $codeAlphabet[random_int(0, $max-1)];
}
return $token;
}