public static NanoPost createNanoPost(String postText, byte[] parentHash, File postAttach) {
        //postText = escapeJson(postText);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);

        NanoPostAttach att = null;
        String postJson = "{}";

        try {
            dos.write(parentHash);
            postJson = new Gson().toJson(new NanoPostInfo(postText, (int) (System.currentTimeMillis() / 1000)));
            dos.writeUTF(postJson);

            if (postAttach == null) {
                dos.writeUTF(""); // there is no attached file
            } else {
                att = new NanoPostAttach(ByteUtils.readBytesFromFile(postAttach), postAttach.getName(), postAttach);
                att.writeToStream(dos);
            }

        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(NanoPostFactory.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(NanoPostFactory.class.getName()).log(Level.SEVERE, null, ex);
        }

        byte[] postHash = EncryptionProvider.sha256(baos.toByteArray());

        return new NanoPost(postHash, parentHash, postJson, att);
    }