Advertisement
Fluffy93

Untitled

Oct 10th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. <?php
  2. //by mssmaks
  3. function uuidFromString($string) {
  4.     $val = md5($string, true);
  5.     $byte = array_values(unpack('C16', $val));
  6.  
  7.     $tLo = ($byte[0] << 24) | ($byte[1] << 16) | ($byte[2] << 8) | $byte[3];
  8.     $tMi = ($byte[4] << 8) | $byte[5];
  9.     $tHi = ($byte[6] << 8) | $byte[7];
  10.     $csLo = $byte[9];
  11.     $csHi = $byte[8] & 0x3f | (1 << 7);
  12.  
  13.     if (pack('L', 0x6162797A) == pack('N', 0x6162797A)) {
  14.         $tLo = (($tLo & 0x000000ff) << 24) | (($tLo & 0x0000ff00) << 8) | (($tLo & 0x00ff0000) >> 8) | (($tLo & 0xff000000) >> 24);
  15.         $tMi = (($tMi & 0x00ff) << 8) | (($tMi & 0xff00) >> 8);
  16.         $tHi = (($tHi & 0x00ff) << 8) | (($tHi & 0xff00) >> 8);
  17.     }
  18.  
  19.     $tHi &= 0x0fff;
  20.     $tHi |= (3 << 12);
  21.    
  22.     $uuid = sprintf(
  23.         '%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x',
  24.         $tLo, $tMi, $tHi, $csHi, $csLo,
  25.         $byte[10], $byte[11], $byte[12], $byte[13], $byte[14], $byte[15]
  26.     );
  27.     $uuid = hex2bin($uuid);
  28.     return $uuid;
  29. }
  30.  
  31. function uuidConvert($string)
  32. {
  33.     $string = uuidFromString("OfflinePlayer:".$string);
  34.     return $string;
  35. }
  36.  
  37. //uuidConvert($_GET['nick']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement