PHP function to generate v4 UUID

前端 未结 15 1366
眼角桃花
眼角桃花 2020-11-22 03:01

So I\'ve been doing some digging around and I\'ve been trying to piece together a function that generates a valid v4 UUID in PHP. This is the closest I\'ve been able to come

15条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 03:42

    on unix systems, use the system kernel to generate a uuid for you.

    file_get_contents('/proc/sys/kernel/random/uuid')
    

    Credit Samveen on https://serverfault.com/a/529319/210994

    Note!: Using this method to get a uuid does in fact exhaust the entropy pool, very quickly! I would avoid using this where it would be called frequently.

提交回复
热议问题