Skip to content

Commit

Permalink
src/lib: Replaced calls to random by rand
Browse files Browse the repository at this point in the history
Deprecated since Erlang/OTP 19.

Link: https://www.erlang.org/doc/deprecations.html#functions-deprecated-in-otp-19
Signed-off-by: Ariel Otilibili <[email protected]>
  • Loading branch information
ariel-anieli committed Nov 19, 2024
1 parent 859d4a4 commit b26f52f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/lib/uuid.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ random_str() ->
%%
random() ->
U = <<
(random:uniform(4294967296) - 1):32,
(random:uniform(4294967296) - 1):32,
(random:uniform(4294967296) - 1):32,
(random:uniform(4294967296) - 1):32
(rand:uniform(4294967296) - 1):32,
(rand:uniform(4294967296) - 1):32,
(rand:uniform(4294967296) - 1):32,
(rand:uniform(4294967296) - 1):32
>>,
format_uuid(U, 4).

Expand All @@ -66,7 +66,7 @@ random() ->
%%
srandom() ->
{A1,A2,A3} = erlang:now(),
random:seed(A1, A2, A3),
rand:seed(A1, A2, A3),
random().

%% @spec sha(Namespace, Name) -> uuid()
Expand Down Expand Up @@ -150,10 +150,10 @@ stop() ->

init(Options) ->
{A1,A2,A3} = proplists:get_value(seed, Options, erlang:now()),
random:seed(A1, A2, A3),
rand:seed(A1, A2, A3),
State = #state{
node = proplists:get_value(node, Options, <<0:48>>),
clock_seq = random:uniform(65536)
clock_seq = rand:uniform(65536)
},
error_logger:info_report("uuid server started"),
{ok, State}.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/websocket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ decode(Data) ->
%%% Internal functions
%%%===================================================================
gen_accept_key() ->
random:seed(erlang:now()),
rand:seed(erlang:now()),
Key = crypto:strong_rand_bytes(16),
KeyStr = base64:encode_to_string(Key),
Accept = binary:list_to_bin(KeyStr ++ "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"),
Expand Down

0 comments on commit b26f52f

Please sign in to comment.