2-- Module : Data.UUID.V3
3-- Copyright : (c) 2010 Antoine Latter
7-- Maintainer : aslatter@gmail.com
8-- Stability : experimental
9-- Portability : portable
12-- This module implements Version 3 UUIDs as specified
15-- These UUIDs identify an object within a namespace,
16-- and are deterministic.
18-- The namespace is identified by a UUID. Several sample
19-- namespaces are enclosed.
32import Data.UUID.Internal
33import qualified Data.UUID.Named as Shared
34import qualified Data.Digest.MD5 as MD5
37-- |Generate a 'UUID' within the specified namespace out of the given
40-- Uses an MD5 hash. The UUID is built from first 128 bits of the hash of
41-- the namespace UUID and the name (as a series of Word8).
42generateNamed :: UUID -- ^Namespace
45generateNamed = Shared.generateNamed hash 3
47hash :: [Word8] -> (Word32, Word32, Word32, Word32)
49 = case map f $ chunk 4 $ MD5.hash bytes of
50 w1:w2:w3:w4:_ -> (w1, w2, w3, w4)
51 _ -> error "Data.UUID.V3.hash: fatal error"
53 where f [b1, b2, b3, b4]
56 , fromIntegral b3 `shiftL` 8
57 , fromIntegral b2 `shiftL` 16
58 , fromIntegral b1 `shiftL` 24
60 f _ = error "Data.UUID.V3.hash: fatal error"
62chunk :: Int -> [a] -> [[a]]
65 go _ ys [] = reverse ys:[]
66 go 0 ys xs = reverse ys:go n [] xs
67 go m ys (x:xs) = go (m-1) (x:ys) xs
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list