I
I
i_want_to_know_everything2015-12-02 15:43:34
PHP
i_want_to_know_everything, 2015-12-02 15:43:34

Generation of unique ID?

uniqid() is the normal way to generate a unique string?
Or is it better to generate a random string and then hash it?
in someone else's code, I mostly meet the second method.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex1442, 2015-12-02
@i_want_to_know_everything

Yes, it's not a bad way.
uniqid() is one function,
and hash + random string is at least 2.
Don't over complicate things

A
Anton, 2015-12-02
@karminski

If you need a string as an ID, then I can advise a compatible RFC 4122solution https://github.com/ramsey/uuid

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question