I had the idea to build a webpage that would display decrypted data fetched from the server. The app.js file on the server reads and decrypts all the data from a specific folder.
var http = require('http');
var path = require('path');
var express = require('express');
var fs = require('fs');
var app = express();
var CryptoJS = require("crypto-js");
app.set('view engine', 'ejs');
var bytes = [];
var markers = fs.readdirSync("views/images");
for (var i = 0; i < markers.length ; ++i) {
bytes[i] = fs.readFileSync("views/images/" +
markers[i]).toString('utf8');
};
The decrypted data is then sent to the webpage.
app.get('/index', function(req, res) {
app.use(express.static(__dirname + '/views'));
try{
for (var i = 0; i < markers.length ; ++i) {
bytes[i] = CryptoJS.AES.decrypt(markers[i],Rf3hgf93).toString(CryptoJS.enc.Utf8);
};
res.render('index',{bytes:bytes});
}catch (err){
res.render('index',{bytes:''});
console.log("error");
};
});
However, the decryption process can take up to 30 seconds due to the large number of files (around 35 files, each approximately 5mb). I am aware that Node.js is single-threaded and lacks concurrency. So, I'm considering using Java or Python instead, as they support multi-threading and concurrency, which could potentially speed up the decryption process.