on master help sign in
[#22] Document Difference Between randomIO & nextRandom
953aef9Pavan Rikhi
uuid-types/Data/UUID/Types/Internal.hs+3−3
@@ -72,9 +72,9 @@ import System.Random
72
72
73
73
74-- |The UUID type. A 'Random' instance is provided which produces
74-- |The UUID type. A 'Random' instance is provided which produces
75−-- version 4 UUIDs as specified in RFC 4122. The 'Storable' and
75+-- insecure version 4 UUIDs as specified in RFC 4122. The 'Storable' and
76−-- 'Binary' instances are compatible with RFC 4122, storing the fields
76+-- 'Binary' instances are compatible with RFC 4122, storing the fields in
77−-- in network order as 16 bytes.
77+-- network order as 16 bytes.
78data UUID
78data UUID
79 = UUID
79 = UUID
80 {-# UNPACK #-} !Word32
80 {-# UNPACK #-} !Word32
uuid/Data/UUID.hs+3−2
@@ -14,8 +14,9 @@ printing Universally Unique Identifiers.
14See <http://en.wikipedia.org/wiki/UUID> for the general idea.
14See <http://en.wikipedia.org/wiki/UUID> for the general idea.
15See <http://tools.ietf.org/html/rfc4122> for the specification.
15See <http://tools.ietf.org/html/rfc4122> for the specification.
16
16
17−* Random UUIDs may be generated using 'Data.UUID.V4.nextRandom' or
17+* Use 'Data.UUID.V4.nextRandom' to generate secure random UUIDs, and your
18−your favorite instance of 'System.Random.Random'.
18+favorite instance of 'System.Random.Random' for faster but insecure
19+generation of UUIDs.
19
20
20* We have an implementation of generating a UUID from the hardware
21* We have an implementation of generating a UUID from the hardware
21MAC address and current system time in "Data.UUID.V1".
22MAC address and current system time in "Data.UUID.V1".
uuid/Data/UUID/V4.hs+2−1
@@ -26,7 +26,8 @@ import Data.UUID.Types.Internal ( buildFromBytes )
26import System.Entropy ( getEntropy )
26import System.Entropy ( getEntropy )
27import Data.ByteString ( unpack )
27import Data.ByteString ( unpack )
28
28
29−-- | Generate a random UUID. Introduced in version 1.2.6.
29+-- | Generate a crytographically secure, random UUID. Introduced in version
30+-- 1.2.6.
30nextRandom :: IO UUID
31nextRandom :: IO UUID
31nextRandom = do
32nextRandom = do
32 [b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf]
33 [b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf]