[英]Speeding up AES decryption in Node js
I wanted to create web page on which would be displayed data, previously decrypted on server.我想创建将显示数据的网页,之前在服务器上解密。 On server in app.js all of data from one folder is read and then decrypted.在 app.js 中的服务器上,读取并解密来自一个文件夹的所有数据。
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');
};
Than data is decrypted and send to page比数据解密并发送到页面
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");
};
});
The thing is, it takes about 30 seconds to decrypt all of this files and send to client.问题是,解密所有这些文件并发送给客户端大约需要 30 秒。 There are about 35 decrypted txt files(each about 5mb).大约有 35 个解密的 txt 文件(每个大约 5mb)。 I know that node js is single-threaded and there is no concurrency.我知道node js是单线程的,没有并发。 So, how can I speed up decrypting process ?那么,我怎样才能加快解密过程呢? Should I use Java/Python instead of node js, as far as I am concerned java is the most suitable language for this process because of multi-threading and concurrency.我应该使用 Java/Python 而不是 node js,就我而言,由于多线程和并发性,java 是最适合这个过程的语言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.