erlang-uuid
erlang-uuid copied to clipboard
random data source
The uuid library uses the 'random' library to generate random numbers. Unfortunately this library defaults to using a constant seed and so the sequence of uuids generated by a new process calling uuid() is always the same.
spawn(fun() -> io:format("~n~p Generated unique id ~p~n", [self(), uuid:v4()]) end).
The above shell code shows what I mean if executed a few times.
A better source for random data in OTP is the crypto module - crypto:rand_bytes/1 uses the openssl psuedo_rand function to generate random data, returned as a binary.