<?php
$random_string = strtoupper(bin2hex(random_bytes(12)));
echo $random_string;
function token($data) {
return mb_substr(strtoupper(preg_replace('~[^-a-z0-9_]+~','', password_hash(strtolower(iconv("utf-8", "us-ascii//TRANSLIT", trim(preg_replace('~[^\\pL0-9_]+~u', '-', $data), "-"))),PASSWORD_BCRYPT, ['cost' => 12,]))),4,16);
}
$first_name = 'Василий';
$last_name = 'Petrov';
$date = date('h:i:s A');
$token = token($first_name . $last_name . $_SERVER['HTTP_USER_AGENT'].$date);
echo 'токен: ' .$token . ' длина: '. strlen($token). "\n";