Skip to content

Instantly share code, notes, and snippets.

@drewjoh
Created April 14, 2010 06:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewjoh/365502 to your computer and use it in GitHub Desktop.
Save drewjoh/365502 to your computer and use it in GitHub Desktop.
1f8fec61-4a6f-9bd5-7f8e-e12325c464c3
1f8fed49-4a6f-9bd5-7f8e-d665dedc0297
1f8fee17-4a6f-9bd5-7f8e-29d1ce3e9e30
1f8feef2-4a6f-9bd5-7f8e-8ce03bebdbdf
1f8fefc7-4a6f-9bd5-7f8e-c22fbedb5390
<?php
// Time based PHP Unique ID
$uid = uniqid(NULL, TRUE);
// Random SHA1 hash
$rawid = strtoupper(sha1(uniqid(rand(), true)));
// Produce the results
$result = substr($uid, 6, 8);
$result .= substr($uid, 0, 4);
$result .= substr(sha1(substr($uid, 3, 3)), 0, 4);
$result .= substr(sha1(substr(time(), 3, 4)), 0, 4);
$result .= strtolower(substr($rawid, 10, 12));
// Return the result
return $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment