Skip to content

Instantly share code, notes, and snippets.

@nojimage
Forked from tanakahisateru/genuuid4.php
Last active November 26, 2019 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nojimage/df00550e9cbc412e479ec9d54939cb67 to your computer and use it in GitHub Desktop.
Save nojimage/df00550e9cbc412e479ec9d54939cb67 to your computer and use it in GitHub Desktop.
NEVER USE this UUIDv4 generator
#!/usr/bin/env php
<?php
/**
* composer init && composer require cakephp/utility:^3.8
*
* Try < PHP 5.6: ./genuuid4.php 65536 | sort | uniq -d
*/
require 'vendor/autoload.php';
use Cake\Utility\Text;
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return $sec + $usec * 1000000;
}
$repeats = isset($argv[1]) ? (int)$argv[1] : 1;
for ($i = 0; $i < $repeats; $i++) {
mt_srand(make_seed()); // !! HAHAHAHAHHHAHA !!
echo Text::uuid() . "\n";
}
@nojimage
Copy link
Author

なるほど。 > メルセンヌツイスタはそんなに衝突しない - Qiita https://qiita.com/blackenedgold/items/52da300456b1e6e1365a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment