blob: 48c67dd25e3490d0a725112eb82ab1f91b2372a9 (
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
|
{-# LANGUAGE OverloadedStrings #-}
module Main
( main
) where
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
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]
|