diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-08-17 19:32:15 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-08-17 19:32:15 +0300 |
commit | 6e20e9bcf9b3181eeee335815e06bb7313c17919 (patch) | |
tree | b3dfa6411b957559e49587a3cff3d304cc643b46 /src/randoms.erl | |
parent | mod_stream_mgmt: Delete 'c2s_init' hook (diff) |
Get rid of deprecated crypto functions
Diffstat (limited to 'src/randoms.erl')
-rw-r--r-- | src/randoms.erl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/randoms.erl b/src/randoms.erl index ad07b47c..7686edcf 100644 --- a/src/randoms.erl +++ b/src/randoms.erl @@ -32,6 +32,20 @@ -define(THRESHOLD, 16#10000000000000000). +-ifdef(RAND_UNIFORM). +get_string() -> + R = rand:uniform(?THRESHOLD), + integer_to_binary(R). + +uniform() -> + rand:uniform(). + +uniform(N) -> + rand:uniform(N). + +uniform(N, M) -> + rand:uniform(M-N+1) + N-1. +-else. get_string() -> R = crypto:rand_uniform(0, ?THRESHOLD), integer_to_binary(R). @@ -44,6 +58,7 @@ uniform(N) -> uniform(N, M) -> crypto:rand_uniform(N, M+1). +-endif. -ifdef(STRONG_RAND_BYTES). bytes(N) -> |