1
- module Random.Secure exposing (Error (..) , int , ints , bool , bools , float , floats )
1
+ module Crypto exposing (Error (..) , int , ints , bool , bools , float , floats )
2
2
3
3
{- | A library for generating cryptographically random values.
4
4
@@ -28,7 +28,7 @@ implementation.
28
28
29
29
-}
30
30
31
- import Native.SecureRandom
31
+ import Native.Crypto
32
32
import Task exposing (Task )
33
33
34
34
{- | A type which represents an error.
@@ -56,7 +56,7 @@ Moreover, the quality of the produced output is dependent on
56
56
-}
57
57
int : Int -> Int -> Task Error Int
58
58
int from to =
59
- Native . SecureRandom . getRandomInt ()
59
+ Native . Crypto . getRandomInt ()
60
60
|> Task . map ( compressInt from to)
61
61
62
62
{- | Generate a list of random 32-bit integers in a given range.
@@ -66,7 +66,7 @@ int from to =
66
66
ints : Int -> Int -> Int -> Task Error (List Int )
67
67
ints from to n =
68
68
-- TODO: Cause invalid argument error when the parametes doesn't make sense.
69
- Native . SecureRandom . getRandomInts ( min 0 n)
69
+ Native . Crypto . getRandomInts ( min 0 n)
70
70
|> Task . map ( List . map ( compressInt from to))
71
71
72
72
{- | Generate a random boolean value.
@@ -78,14 +78,14 @@ ints from to n =
78
78
-}
79
79
bool : Task Error Bool
80
80
bool =
81
- Native . SecureRandom . getRandomInt ()
81
+ Native . Crypto . getRandomInt ()
82
82
|> Task . map ( \ x -> x % 2 == 0 )
83
83
84
84
{- | Generate a list of random boolean values.
85
85
-}
86
86
bools : Int -> Task Error (List Bool )
87
87
bools n =
88
- Native . SecureRandom . getRandomInts ( min 0 n)
88
+ Native . Crypto . getRandomInts ( min 0 n)
89
89
|> Task . map ( List . map ( \ x -> x % 2 == 0 ))
90
90
91
91
{- | Generate a random floating point number in a given range.
@@ -94,7 +94,7 @@ bools n =
94
94
-}
95
95
float : Float -> Float -> Task Error Float
96
96
float from to =
97
- Native . SecureRandom . getRandomInt ()
97
+ Native . Crypto . getRandomInt ()
98
98
|> Task . map ( compressFloat from to)
99
99
100
100
{- | Generate a list of random floating point numbers in a given range.
@@ -103,7 +103,7 @@ float from to =
103
103
-}
104
104
floats : Float -> Float -> Int -> Task Error (List Float )
105
105
floats from to n =
106
- Native . SecureRandom . getRandomInts ( min 0 n)
106
+ Native . Crypto . getRandomInts ( min 0 n)
107
107
|> Task . map ( List . map ( compressFloat from to))
108
108
109
109
compressInt : Int -> Int -> Int -> Int
0 commit comments