[erlang-questions] How to not cache a certain function in yaws

Frej Drejhammar <>
Tue Mar 3 12:07:21 CET 2009


> The problem is that random is initailized with a default seed in each
> process. And since You dont seed it yourself it will generate the same
> sequence of numbers in each process.
>
> add something like this
>
> {A1,A2,A3} = now(),
> random:seed(A1, A2, A3)
>
> before the call random:uniform(123)

Congratulations, you just made your random string (nearly)
deterministic... :-)

If your random string is used as for anything security related you
should use crypto:rand_uniform/2 instead or perhaps
crypto:rand_bytes/1 and hexify or encode the returned binary to your
liking.

Regards,

--Frej



More information about the erlang-questions mailing list