diff --git a/src/Generators/MachineId.php b/src/Generators/MachineId.php new file mode 100644 index 0000000..3edb48b --- /dev/null +++ b/src/Generators/MachineId.php @@ -0,0 +1,76 @@ + $system->getMachine(), + 'operatingSystem' => [ + 'name' => $system->getName(), + 'version' => $system->getVersion(), + 'release' => $system->getRelease() + ], + 'hostname' => $system->getHostname(), + 'cpuCores' => $system->getCpuCores(), + 'macAddress' => $system->getMacAddress() + ]; + } else { + $metadata = [ + 'machine' => php_uname('m'), + 'operatingSystem' => [ + 'name' => php_uname('s'), + 'version' => php_uname('v'), + 'release' => php_uname('r') + ], + 'hostname' => php_uname('n'), + 'cpuCores' => 1, + 'macAddress' => implode(':', str_split(substr(md5('none'), 0, 12), 2)) + ]; + } + + $uri = new Uri(); + + $metadata['domain'] = $uri->getHost(); + $metadata['ipAddress'] = $_SERVER['SERVER_ADDR']; + + $string = json_encode($metadata); + $string = md5($string); + + // Converts to UUID (Universally Unique Identifier) + $parts[] = substr($string, 0, 8); + $parts[] = substr($string, 8, 4); + $parts[] = substr($string, 12, 4); + $parts[] = substr($string, 16, 4); + $parts[] = substr($string, 20, 12); + + $parts = array_map('strtoupper', $parts); + + return implode('-', $parts); + } +} \ No newline at end of file diff --git a/src/Generators/Token.php b/src/Generators/Token.php new file mode 100644 index 0000000..6ba39f4 --- /dev/null +++ b/src/Generators/Token.php @@ -0,0 +1,94 @@ +