blob: e1acb5ddf46d764d6209b21236b1faac91b9781f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
{-# LANGUAGE OverloadedStrings #-}
module Main where
import System.Environment (getArgs)
import System.Process (callProcess)
import ZeroBin.SJCL (encrypt)
import 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
-- nodejs is a Debian's thing, others may have simple "node"
getText :: IO BS.ByteString
getText = do
args <- map C.pack `fmap` getArgs
if null args
then return "heinrich hertz"
else return . BS.intercalate " " $ args
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
]
|