Class MachineId


  • public final class MachineId
    extends Object
    Utility for generating machine ID.

    It works in three steps:

    1. Create a string containing HOSTNAME, MAC and IP;
    2. Create a hash of the string using SHA-256 algorithm;
    3. Create the identifier using part of the resulting 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