Пример #1
0
 /**
  * Create a version 5 UUID based upon a name and a given namespace
  *
  * @param   util.UUID namespace
  * @param   string name
  * @return  util.UUID
  */
 public static function sha1UUID(self $namespace, $name)
 {
     $bytes = sha1($namespace->getBytes() . iconv(xp::ENCODING, 'utf-8', $name));
     return new self(array(5, hexdec(substr($bytes, 0, 8)), hexdec(substr($bytes, 8, 4)), hexdec(substr($bytes, 12, 4)) & 0xfff, hexdec(substr($bytes, 16, 4)) & 0x3fff | 0x8000, array_map('hexdec', str_split(substr($bytes, 20, 12), 2))));
 }