How unique is UUID?

后端 未结 11 2020
终归单人心
终归单人心 2020-11-22 05:40

How safe is it to use UUID to uniquely identify something (I\'m using it for files uploaded to the server)? As I understand it, it is based off random numbers. However, it s

11条回答
  •  离开以前
    2020-11-22 05:58

    For UUID4 I make it that there are approximately as many IDs as there are grains of sand in a cube-shaped box with sides 360,000km long. That's a box with sides ~2 1/2 times longer than Jupiter's diameter.

    Working so someone can tell me if I've messed up units:

    • volume of grain of sand 0.00947mm^3 (Guardian)
    • UUID4 has 122 random bits -> 5.3e36 possible values (wikipedia)
    • volume of that many grains of sand = 5.0191e34 mm^3 or 5.0191e+25m^3
    • side length of cubic box with that volume = 3.69E8m or 369,000km
    • diameter of Jupiter: 139,820km (google)

提交回复
热议问题