Commit 673ad74b authored by Vaibhav Sagar's avatar Vaibhav Sagar

ipython-kernel: use cryptonite instead of SHA

parent 65ee1299
...@@ -39,17 +39,18 @@ library ...@@ -39,17 +39,18 @@ library
bytestring , bytestring ,
cereal , cereal ,
containers , containers ,
cryptonite ,
directory , directory ,
temporary , temporary ,
filepath , filepath ,
process , process ,
memory ,
mtl , mtl ,
text , text ,
transformers , transformers ,
unordered-containers, unordered-containers,
uuid , uuid ,
zeromq4-haskell , zeromq4-haskell
SHA
-- Example program -- Example program
executable simple-calc-example executable simple-calc-example
......
...@@ -17,12 +17,14 @@ module IHaskell.IPython.ZeroMQ ( ...@@ -17,12 +17,14 @@ module IHaskell.IPython.ZeroMQ (
import Control.Concurrent import Control.Concurrent
import Control.Exception import Control.Exception
import Control.Monad import Control.Monad
import qualified Crypto.Hash as Hash
import Crypto.Hash.Algorithms (SHA256)
import qualified Crypto.MAC.HMAC as HMAC
import Data.Aeson import Data.Aeson
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as Char import qualified Data.ByteString.Char8 as Char
import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Lazy as LBS
import Data.Char import Data.Char
import Data.Digest.Pure.SHA as SHA
import Data.Monoid ((<>)) import Data.Monoid ((<>))
import qualified Data.Text.Encoding as Text import qualified Data.Text.Encoding as Text
import System.ZMQ4 as ZMQ4 hiding (stdin) import System.ZMQ4 as ZMQ4 hiding (stdin)
...@@ -336,7 +338,7 @@ sendMessage debug hmacKey socket message = do ...@@ -336,7 +338,7 @@ sendMessage debug hmacKey socket message = do
-- Compute the HMAC SHA-256 signature of a bytestring message. -- Compute the HMAC SHA-256 signature of a bytestring message.
hmac :: ByteString -> ByteString hmac :: ByteString -> ByteString
hmac = Char.pack . SHA.showDigest . SHA.hmacSha256 (LBS.fromStrict hmacKey) . LBS.fromStrict hmac = Char.pack . show . (HMAC.hmacGetDigest :: HMAC.HMAC SHA256 -> Hash.Digest SHA256) . HMAC.hmac hmacKey
-- Pieces of the message. -- Pieces of the message.
head = header message head = header message
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment