aboutsummaryrefslogtreecommitdiff
path: root/nodejs/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'nodejs/Main.hs')
-rw-r--r--nodejs/Main.hs25
1 files changed, 12 insertions, 13 deletions
diff --git a/nodejs/Main.hs b/nodejs/Main.hs
index 3cf74d9..48c67dd 100644
--- a/nodejs/Main.hs
+++ b/nodejs/Main.hs
@@ -1,18 +1,19 @@
{-# LANGUAGE OverloadedStrings #-}
-module Main where
+module Main
+ ( main
+ ) where
-import System.Environment (getArgs)
-import System.Process (callProcess)
-import Web.ZeroBin.SJCL (encrypt)
-import Web.ZeroBin.Utils (makePassword)
import qualified Data.Aeson as JSON
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.Lazy as L
+import System.Environment (getArgs)
+import System.Process (callProcess)
+import Web.ZeroBin.SJCL (encrypt)
+import Web.ZeroBin.Utils (makePassword)
-- nodejs is a Debian's thing, others may have simple "node"
-
getText :: IO BS.ByteString
getText = do
args <- map C.pack `fmap` getArgs
@@ -23,10 +24,8 @@ getText = do
main :: IO ()
main = do
password <- makePassword 32
- text <- getText
- cont <- encrypt password text
- callProcess "nodejs" [ "nodejs/decrypt.js"
- , password
- , C.unpack . L.toStrict $ JSON.encode cont
- ]
-
+ text <- getText
+ cont <- encrypt password text
+ callProcess
+ "nodejs"
+ ["nodejs/decrypt.js", password, C.unpack . L.toStrict $ JSON.encode cont]