Permalink
Browse files

SHA: add Git.SHA

Include showDigestBS from Data.Digest.Pure.SHA
  • Loading branch information...
1 parent d6c47e8 commit 15f00b09ed024f75258537f64d7e253f98eeb61e @kfish committed May 10, 2011
Showing with 23 additions and 0 deletions.
  1. +22 −0 Git/SHA.hs
  2. +1 −0 ght.cabal
View
@@ -0,0 +1,22 @@
+{-# OPTIONS -Wall #-}
+
+module Git.SHA (
+ showDigestBS
+) where
+
+import Data.Bits
+import Data.ByteString (ByteString)
+import qualified Data.ByteString as BS
+import Data.Char
+
+------------------------------------------------------------
+-- From Data.Digest.Pure.SHA
+
+-- |Prints out a bytestring in hexadecimal. Just for convenience.
+showDigestBS :: ByteString -> String
+showDigestBS bs = foldr paddedShowHex [] (BS.unpack bs)
+ where
+ paddedShowHex x xs = intToDigit (fromIntegral (x `shiftR` 4))
+ : intToDigit (fromIntegral (x .&. 0xf))
+ : xs
+
View
@@ -30,6 +30,7 @@ library
Git.Pack
Git.PackIndex
Git.Path
+ Git.SHA
------------------------------------------------------------
-- ght tool

0 comments on commit 15f00b0

Please sign in to comment.