Permalink
Browse files

Use crypto:rand_uniform instead of random:uniform

  • Loading branch information...
alexeyshch committed Jan 4, 2016
1 parent 94c620c commit fb8a51136519a190145265736c4243095e2516ec
Showing with 5 additions and 16 deletions.
  1. +5 −16 src/randoms.erl
@@ -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).

0 comments on commit fb8a511

Please sign in to comment.