implement reading the secret key from stdin
This commit is contained in:
parent
5072667e16
commit
d70a3c9381
1 changed files with 6 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
|
import Control.Exception
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import qualified Data.ByteString as B
|
import qualified Data.ByteString as B
|
||||||
import qualified Data.ByteString.Base64 as B64
|
import qualified Data.ByteString.Base64 as B64
|
||||||
|
|
@ -26,7 +27,11 @@ main = do
|
||||||
_ -> sign
|
_ -> sign
|
||||||
|
|
||||||
encrypt = do
|
encrypt = do
|
||||||
encryptedFile <- T.encodeUtf8 <$> getPrivateKey
|
let key = catch getPrivateKey
|
||||||
|
(\e -> do let err = show (e :: IOException)
|
||||||
|
hPutStr stderr ("Warning: Couldn't get key from file (" ++ err ++ "), reading from stdin\n")
|
||||||
|
T.getContents)
|
||||||
|
encryptedFile <- T.encodeUtf8 <$> key
|
||||||
path <- getPrivateKeyPath
|
path <- getPrivateKeyPath
|
||||||
B.writeFile path =<< encryptData encryptedFile
|
B.writeFile path =<< encryptData encryptedFile
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue