PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/application/helpers/uuid.php

https://github.com/lmorchard/friendfeedarchiver
PHP | 24 lines | 11 code | 2 blank | 11 comment | 0 complexity | 38f08e2336c31382a95141528b359ef3 MD5 | raw file
  1. <?php
  2. /**
  3. * Generate UUIDs
  4. *
  5. * @package OpenInterocitor
  6. * @author l.m.orchard@pobox.com
  7. * @licence Share and Enjoy
  8. */
  9. class uuid_Core
  10. {
  11. /**
  12. * Produce a UUID per RFC 4122, version 4
  13. * See also: http://us.php.net/manual/en/function.uniqid.php#69164
  14. */
  15. public static function uuid() {
  16. return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  17. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
  18. mt_rand( 0, 0x0fff ) | 0x4000,
  19. mt_rand( 0, 0x3fff ) | 0x8000,
  20. mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
  21. }
  22. }