Generating a globally unique identifier in Java

前端 未结 6 1895
广开言路
广开言路 2020-11-29 04:32

Summary: I\'m developing a persistent Java web application, and I need to make sure that all resources I persist have globally unique identifiers to prevent

6条回答
  •  被撕碎了的回忆
    2020-11-29 04:37

    From memory the RMI remote packages contain a UUID generator. I don't know whether thats worth looking into.

    When I've had to generate them I typically use a MD5 hashsum of the current date time, the user name and the IP address of the computer. Basically the idea is to take everything that you can find out about the computer/person and then generate a MD5 hash of this information.

    It works really well and is incredibly fast (once you've initialised the MessageDigest for the first time).

提交回复
热议问题