Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Changed random number generator to crypto:rand_uniform(), so that the…
… uuids are not always the same sequence. I guess that is the idea of a uuid?
  • Loading branch information
shoehn committed Oct 15, 2011
commit f3b5f4d5a04eb6f076f48cb8da309475efdae875
3 changes: 2 additions & 1 deletion uuid.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@

% Generates a random binary UUID.
v4() ->
v4(random:uniform(round(math:pow(2, 48))) - 1, random:uniform(round(math:pow(2, 12))) - 1, random:uniform(round(math:pow(2, 32))) - 1, random:uniform(round(math:pow(2, 30))) - 1).
v4(crypto:rand_uniform(1, round(math:pow(2, 48))) - 1, crypto:rand_uniform(1, round(math:pow(2, 12))) - 1, crypto:rand_uniform(1, round(math:pow(2, 32))) - 1, crypto:rand_uniform(1, round(math:pow(2, 30))) - 1).

v4(R1, R2, R3, R4) ->
<<R1:48, 4:4, R2:12, 2:2, R3:32, R4: 30>>.

Expand Down