Class RandomGUID


  • public class RandomGUID
    extends Object
    This class generates Global Unique Ids (GUIDS).

    RandomGUID generates truly random GUIDs by combining the system's IP address (name/IP), system time in milliseconds, and a very large random number joined together in a single String that is then passed through an MD5 hash.

    It's not possible to access the seed information (IP, time, random number) from the resulting GUIDs as the MD5 hash algorithm provides one way encryption.

    • Constructor Detail

      • RandomGUID

        public RandomGUID()
        With no specification of security option, this constructor defaults to lower security, high performance.
      • RandomGUID

        public RandomGUID​(boolean secure)
        Setting secure true enables each random number generated to be cryptographically strong.

        Secure false defaults to the standard Random function seeded with a single cryptographically strong random number.

    • Method Detail

      • toString

        public String toString()
        Convert to the standard format for GUID (Useful for SQL Server UniqueIdentifiers, etc.)

        Example: C2FEEEAC-CFCD-11D1-8B05-00600806D9B6

        Overrides:
        toString in class Object