Skip to content

random data source #2

Open
Open
@archaelus

Description

@archaelus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions