Skip to content

Commit

Permalink
clean up deprecated methods from random module
Browse files Browse the repository at this point in the history
  • Loading branch information
tvv committed Sep 8, 2016
1 parent 1b8f044 commit 7d953d7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/uuid.erl
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ uuid1_time() ->
%% @doc Use ClockSeq if supplied otherwise Generate random clock sequence.
-spec uuid1_clockseq(null | binary()) -> <<_:14>>.
uuid1_clockseq(null) ->
random:seed(now_xor_pid()),
Rnd = random:uniform(2 bsl 14 - 1),
rand:seed(exsplus),
Rnd = rand:uniform(2 bsl 14 - 1),
<<Rnd:14>>;
uuid1_clockseq(ClockSeqArg) ->
<<_:14>> = ClockSeqArg. % make 14 bits wide
Expand Down Expand Up @@ -175,7 +175,7 @@ uuid4() ->
% Set all other bits pseudo-randomly chosen values
% (as generated by caller).

<<U0:32, U1:16, _:4, U2:12, _:2, U3:30, U4:32>> = crypto:rand_bytes(16),
<<U0:32, U1:16, _:4, U2:12, _:2, U3:30, U4:32>> = crypto:strong_rand_bytes(16),

<<U0:32, U1:16, ?UUIDv4:4, U2:12, ?VARIANT10:2, U3:30, U4:32>>.

Expand Down Expand Up @@ -332,7 +332,7 @@ hwaddr_find(_) ->
-spec hwaddr_random() -> binary().
hwaddr_random() ->
%% No interface, create random 48-bit number with bit 8 set to one.
<<RndHi:7, _:1, RndLow:40>> = crypto:rand_bytes(6),
<<RndHi:7, _:1, RndLow:40>> = crypto:strong_rand_bytes(6),
%% Set 8 to 1
<<RndHi:7, 1:1, RndLow:40>>.

Expand Down Expand Up @@ -412,5 +412,5 @@ is_valid(_, _) -> false.
-spec now_xor_pid() -> {pos_integer(), pos_integer(), pos_integer()}.
now_xor_pid() ->
PidSum = erlang:phash2(self()),
<<N0:32, N1:32, N2:32>> = crypto:rand_bytes(12),
<<N0:32, N1:32, N2:32>> = crypto:strong_rand_bytes(12),
{N0 bxor PidSum, N1 bxor PidSum, N2 bxor PidSum}.

0 comments on commit 7d953d7

Please sign in to comment.