- java.lang.Object
-
- com.github.f4b6a3.uuid.util.MachineId
-
public final class MachineId extends Object
Utility for generating machine ID.It works in three steps:
- Create a string containing HOSTNAME, MAC and IP;
- Create a hash of the string using SHA-256 algorithm;
- Create the identifier using part of the resulting hash.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]getMachineHash()Returns the machine hash in a byte array.static StringgetMachineHexa()Returns the machine hash in hexadecimal format.static longgetMachineId()Returns a number generated from the machine hash.static StringgetMachineString()Returns a string containing host name, MAC and IP.static UUIDgetMachineUuid()Returns a UUID generated from the machine hash.
-
-
-
Method Detail
-
getMachineId
public static long getMachineId()
Returns a number generated from the machine hash.It uses the first 8 bytes of the machine hash.
- Returns:
- a number
-
getMachineUuid
public static UUID getMachineUuid()
Returns a UUID generated from the machine hash.It uses the first 16 bytes of the machine hash.
The UUID version is 4.
- Returns:
- a UUID
-
getMachineHexa
public static String getMachineHexa()
Returns the machine hash in hexadecimal format.The returning string has 64 chars.
- Returns:
- a string
-
getMachineHash
public static byte[] getMachineHash()
Returns the machine hash in a byte array.The returning array has 32 bytes (256 bits).
- Returns:
- a byte array
-
getMachineString
public static String getMachineString()
Returns a string containing host name, MAC and IP.Output format: "hostname 11-11-11-11-11-11 222.222.222.222"
- Returns:
- a string
-
-