function keygen($length) {
$token = '';
$tokenlength = round($length * 4 / 3);
for ($i = 0; $i < $tokenlength; ++$i) {
$token .= chr(rand(32, 1024));
}
$token = base64_encode(str_shuffle($token));
return substr($token, 0, $length);
}
From: https://github.com/gladchinda/keygen-php/blob/master/src/Keygen/Generators/TokenGenerator.php
转载原文:https://www.imaegoo.com/2020/aes-key-generator/