Hello, I'm trying to understand how to use an npm package called simplecrypto: https://ift.tt/2RY84kn idea would be to create a simple form, where a user could type a message and add a secret key to let someone decrypt it later.The package seems quite simple: 3 main functions:1- encrypt() to encrypt2- setSecret() to set the key3- decrypt() to decryptFor testing purposes, I set a super basic express app:const express = require("express"); const app = express(); const SimpleCrypto = require("simple-crypto-js").default; app.listen(3000); app.use(SimpleCrypto); app.use(express.static(__dirname + "/public")); //ROUTES //home app.get("/", (request, response, next) =>{ response.sendFile(__dirname + "/public/index.html"); }); And a basic html:
Then I create an app.post route to handle the form and encrypt the message:app.post("/msg-encrypt", (request, response, next) =>{ const {msg, key} = request.body; setSecret(key) encrypt(msg) response.send(msg, key); }); For the moment, I just want to see if the message can be crypted by displaying it on a basic page. Then I will create a proper redirection, use HBS, etc. But right now, I can't make this encryption package work properly. Any idea?
Submitted November 15, 2018 at 01:51PM by MonsieurLeland
No comments:
Post a Comment