protected function generateToken(string $lockTo) : array
{
$index = Base64::encode(\random_bytes(18));
$token = Base64::encode(\random_bytes(33));
$this->session[$this->sessionIndex][$index] = ['created' => \intval(\date('YmdHis')), 'uri' => isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : $this->server['SCRIPT_NAME'], 'token' => $token];
if (\preg_match('#/$#', $lockTo)) {
$lockTo = Binary::safeSubstr($lockTo, 0, Binary::safeStrlen($lockTo) - 1);
}
$this->session[$this->sessionIndex][$index]['lockTo'] = $lockTo;
$this->recycleTokens();
return [$index, $token];
}