Use crypto:rand_uniform instead of random:uniform

This commit is contained in:
Alexey Shchepin 2016-01-04 13:55:25 +03:00
parent 94c620cc27
commit fb8a511365
1 changed files with 5 additions and 16 deletions

View File

@ -29,23 +29,12 @@
-export([get_string/0]).
-export([start/0, init/0]).
-export([start/0]).
start() ->
register(random_generator, spawn(randoms, init, [])).
init() ->
random:seed(p1_time_compat:timestamp()), loop().
loop() ->
receive
{From, get_random, N} ->
From ! {random, random:uniform(N)}, loop();
_ -> loop()
end.
ok.
get_string() ->
random_generator ! {self(), get_random, 65536 * 65536},
receive
{random, R} -> jlib:integer_to_binary(R)
end.
R = crypto:rand_uniform(0, 16#10000000000000000),
jlib:integer_to_binary(R).