module Codec.Digest.SHA.Misc where

import qualified Data.ByteString as B
import qualified Numeric(showHex)
import Data.Word(Word8)

-- | Converts a ByteString to hexadeximal string format
showBSasHex :: B.ByteString -> String
showBSasHex bs | B.null bs = ""
showBSasHex bs = showHex (B.index bs 0) $ showBSasHex (B.drop 1 bs)

showHex :: Word8 -> String -> String
showHex n rest | n < 0x10 = Numeric.showHex n ('0' : rest)
showHEx n rest = Numeric.showHex n rest