@@ -1,6 +1,6 @@
2 Module : Data.UUID.V4
2 Module : Data.UUID.V4
3− Copyright : (c) 2012 Antoine Latter
3+ Copyright : (c) 2012-2016 Antoine Latter
5 License : BSD-style
5 License : BSD-style
@@ -21,8 +21,14 @@
21module Data.UUID.V4 (nextRandom) where
21module Data.UUID.V4 (nextRandom) where
23import Data.UUID
23import Data.UUID
24−import qualified System.Random as R
24+import Data.UUID.Types.Internal ( buildFromBytes )
26+import Crypto.Random.Entropy ( getEntropy )
27+import Data.ByteString ( unpack )
26-- | Generate a random UUID. Introduced in version 1.2.6.
29-- | Generate a random UUID. Introduced in version 1.2.6.
27nextRandom :: IO UUID
30nextRandom :: IO UUID
28−nextRandom = R.randomIO
31+nextRandom = do
32+ [b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf]
33+ <- unpack `fmap` getEntropy 16
34+ return $ buildFromBytes 4 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf