@@ -33,6 +33,7 @@ import System.EntropyNix
35import qualified Data.ByteString as B
35import qualified Data.ByteString as B
36+import Control.Exception (bracket)
37-- |Get a specific number of bytes of cryptographically
38-- |Get a specific number of bytes of cryptographically
38-- secure random data using the system-specific facilities.
39-- secure random data using the system-specific facilities.
@@ -41,8 +42,4 @@ import qualified Data.ByteString as B
41-- Windows. In short, this entropy is considered cryptographically secure
42-- Windows. In short, this entropy is considered cryptographically secure
42-- but not true entropy.
43-- but not true entropy.
43getEntropy :: Int -> IO B.ByteString
44getEntropy :: Int -> IO B.ByteString
44−getEntropy n = do
45+getEntropy = bracket openHandle closeHandle . flip hGetEntropy