diff --git a/Git/Libgit2.hs b/Git/Libgit2.hs
--- a/Git/Libgit2.hs
+++ b/Git/Libgit2.hs
@@ -41,7 +41,10 @@
        , lgLoadPackFileInMemory
        , lgReadFromPack
        , lgWithPackFile
+       , SHA
        , oidToSha
+       , shaToOid
+       , shaToText
        , openLgRepository
        , runLgRepository
        , strToOid
@@ -60,6 +63,7 @@
 import           Control.Monad.Trans.Resource
 import           Data.Bits ((.|.))
 import qualified Data.ByteString as B
+import qualified Data.ByteString.Base16 as B16
 import qualified Data.ByteString.Unsafe as BU
 import           Data.HashMap.Strict (HashMap)
 import qualified Data.HashMap.Strict as HashMap
@@ -1114,7 +1118,7 @@
         debug "Discovering the hash used to identify the pack file"
         sha <- liftIO $ oidToSha =<< c'git_indexer_stream_hash idxPtr
         debug $ "The hash used is: " ++ show sha
-        return sha
+        return (shaToText sha)
 
 strToOid :: String -> IO (ForeignPtr C'git_oid)
 strToOid oidStr = do
@@ -1125,10 +1129,22 @@
         when (r < 0) $ throwIO Git.OidCopyFailed
         return ptr
 
-oidToSha :: Ptr C'git_oid -> IO Text
-oidToSha oidPtr = allocaBytes 42 $ \oidStr ->
-    T.decodeUtf8 <$> (B.packCString =<< c'git_oid_tostr oidStr 41 oidPtr)
+type SHA = B.ByteString
 
+oidToSha :: Ptr C'git_oid -> IO B.ByteString
+oidToSha oidPtr =
+    B.packCStringLen (castPtr oidPtr, sizeOf (undefined :: C'git_oid))
+
+shaToOid :: B.ByteString -> IO (ForeignPtr C'git_oid)
+shaToOid bs = BU.unsafeUseAsCString bs $ \bytes -> do
+    ptr <- mallocForeignPtr
+    withForeignPtr ptr $ \ptr' -> do
+        c'git_oid_fromraw ptr' (castPtr bytes)
+        return ptr
+
+shaToText :: B.ByteString -> Text
+shaToText = T.decodeUtf8 . B16.encode
+
 lgWritePackFile :: Git.MonadGit m => FilePath -> LgRepository m ()
 lgWritePackFile packFile = do
     -- jww (2013-04-23): This would be much more efficient (we already have
@@ -1231,12 +1247,12 @@
         debug "Calling function using in-memory odb"
         f odbPtr
 
-lgReadFromPack :: FilePath -> Text -> Bool
+lgReadFromPack :: FilePath -> B.ByteString -> Bool
                -> IO (Maybe (C'git_otype, CSize, B.ByteString))
 lgReadFromPack idxPath sha metadataOnly =
     alloca $ \objectPtrPtr ->
     lgWithPackFile idxPath $ \odbPtr -> do
-        foid <- liftIO $ strToOid (T.unpack sha)
+        foid <- liftIO $ shaToOid sha
         if metadataOnly
             then liftIO $ alloca $ \sizePtr -> alloca $ \typPtr -> do
                 r <- withForeignPtr foid $
diff --git a/gitlib-libgit2.cabal b/gitlib-libgit2.cabal
--- a/gitlib-libgit2.cabal
+++ b/gitlib-libgit2.cabal
@@ -1,5 +1,5 @@
 Name:                gitlib-libgit2
-Version:             1.2.0
+Version:             1.2.1
 Synopsis:            Libgit2 backend for gitlib
 License-file:        LICENSE
 License:             MIT
@@ -41,6 +41,7 @@
         , hlibgit2             >= 0.18.0.7
         , attempt              >= 0.4.0
         , bytestring           >= 0.9.2.1
+        , base16-bytestring    >= 0.1.1.5
         , conduit              >= 0.5.5
         , containers           >= 0.4.2
         , data-default         >= 0.5.0
