Created
November 18, 2012 01:15
-
-
Save hexathos/4102410 to your computer and use it in GitHub Desktop.
Create UniqueID in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function genUUID($prefix=null,$maxlength=36) | |
{ | |
$s = strtoupper( | |
hash( | |
'whirlpool',hash('sha1', | |
microtime(true).crypt( | |
uniqid( | |
rand(), | |
true) | |
) | |
) | |
) | |
); | |
$guidText = | |
substr($s,0,8) . '-' . | |
substr($s,8,4) . '-' . | |
substr($s,12,4). '-' . | |
substr($s,16,4). '-' . | |
substr($s,20,$maxlength); | |
return $prefix.$guidText; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment