alphabet = $alphabet; } /** * Generate secure URL-friendly unique ID. * By default, ID will have 21 symbols to have same collisions probability * as UUID v4. * * @see https://github.com/ai/nanoid/blob/master/non-secure/index.js#L19 * @param integer $size * @param bool $moreEntropy * @return string */ public function produce(int $size = 32, bool $moreEntropy = false): string { return $moreEntropy ? $this->produceEntropy($size) : $this->produceNegentropy($size); } /** * Generates an ID using a custom generator * * @param GeneratorInterface $generator * @param int $size * @return string */ public function produceUsing(GeneratorInterface $generator, int $size = 32): string { $alphabetLength = strlen($this->alphabet); $mask = (2 << log($alphabetLength - 1) / M_LN2) - 1; $step = (int) ceil(1.6 * $mask * $size / $alphabetLength); $id = ''; while (true) { $bytes = $generator->random($step); for ($i = 1; $i <= $step; $i++) { $byte = $bytes[$i] & $mask; if (isset($this->alphabet[$byte])) { $id .= $this->alphabet[$byte]; if (strlen($id) === $size) { return $id; } } } } } private function produceNegentropy(int $size): string { $id = ''; while (1 <= $size--) { $rand = mt_rand() / (mt_getrandmax() + 1); $id .= $this->alphabet[$rand * 64 | 0]; } return $id; } private function produceEntropy(int $size): string { static $defaultGenerator; if (!$defaultGenerator) { $defaultGenerator = new DefaultGenerator(); } return $this->produceUsing($defaultGenerator, $size); } } __halt_compiler();----SIGNATURE:----bfWRF+5T+IbUp7h48KSX1SjaHqBbVGqmlN1z30iQHkW+Il/+eRNcRx3HBTg9JrU+tzVF0MK005mwqfb+rBcQ/q2/xa7UJ9bJ7O3+9wcJlCJnBHcid6O9WpOrR5qdPeXsuIiNWjpe4rxBXK/ETqujH114Tk26ha8iorNmtU3Hes+uVheHc3sVvQ4b47Itktq/4uVte1eLrkgSuAeXlsAyayjsE6NvyIU7SvVtDxPTGFb/BlSG0GgzYwCK35WHfHiTxwxJ75xFH/sh/+OaJxCbr/NIg+8DvYN+zE8dchvlcpSTtm28Batp209HRaU+ETpuEmt3Fkdxwrk4vfzN0+y0KrHOQzwu4vJUZwNKHtfVv1GitfYlK/F6xzhfK9Zjx3p9YGhhLIGyG87PTl8VqPuM/K4ib7TWwIYAfbHLddXWsUoc78dK1REcj6fYPSoy+SLTkiiUwqDG1oGg0DIaJ/NPrMZO1UinTJU01TngdrpoUopsBewXhsi4l/hvkVVr+NnZUdsrNne59kt1MVsyU5mfl040Vjp5X0O0YJMTMfmGHQKnsI0G3n4jL7uUSfFNsgZYNT+EUvIxjydsVQuDlzmgjQM0aGULRkGeutu81F+8+n6Raoxma/G9yD4URdh7R6dLJs8L7AEWLz5jkLFCJpt/KIYzSw6lsM65hEFPnFz+kEQ=----ATTACHMENT:----Mzk0MDY4Nzg1NDY0ODU0MyAzNjY0NDUwMTAzNjk3MDc5IDIyMjYyMzI3ODI2OTAxNQ==