on master help sign in
[#22] Document Difference Between randomIO & nextRandom

The `Random` class should be used for UUIDs where cryptographic security is not necessary, while `Data.UUID.v4.nextRandom` should be used for UUIDs that need to be cryptographically secure. Refs #22

commit953aef9e4b2d5800e7f4289c954cc8d30fa06fed authorPavan Rikhi <pavan.rikhi@gmail.com> dateTue 20 Jun 2017, 19:53 (9 years ago) parentd6871e4
3 files changed+8−6
uuid-types/Data/UUID/Types/Internal.hs+3−3 uuid/Data/UUID.hs+3−2 uuid/Data/UUID/V4.hs+2−1
uuid-types/Data/UUID/Types/Internal.hs+3−3
@@ -72,9 +72,9 @@ import System.Random
7272
7373
7474-- |The UUID type. A 'Random' instance is provided which produces
75−-- version 4 UUIDs as specified in RFC 4122. The 'Storable' and
76−-- 'Binary' instances are compatible with RFC 4122, storing the fields
77−-- in network order as 16 bytes.
75+-- insecure version 4 UUIDs as specified in RFC 4122. The 'Storable' and
76+-- 'Binary' instances are compatible with RFC 4122, storing the fields in
77+-- network order as 16 bytes.
7878data UUID
7979 = UUID
8080 {-# UNPACK #-} !Word32
uuid/Data/UUID.hs+3−2
@@ -14,8 +14,9 @@ printing Universally Unique Identifiers.
1414See <http://en.wikipedia.org/wiki/UUID> for the general idea.
1515See <http://tools.ietf.org/html/rfc4122> for the specification.
1616
17−* Random UUIDs may be generated using 'Data.UUID.V4.nextRandom' or
18−your favorite instance of 'System.Random.Random'.
17+* Use 'Data.UUID.V4.nextRandom' to generate secure random UUIDs, and your
18+favorite instance of 'System.Random.Random' for faster but insecure
19+generation of UUIDs.
1920
2021* We have an implementation of generating a UUID from the hardware
2122MAC 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 )
2626import System.Entropy ( getEntropy )
2727import Data.ByteString ( unpack )
2828
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.
3031nextRandom :: IO UUID
3132nextRandom = do
3233 [b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf]