这是我的第一个问题。英语不是我的第一语言。我有一个包含大约 800K 行的文件。我必须使用 sjcl 库读取和加密它们。到现在为止,我唯一做的就是这几行:
var sjcl = require('sjcl/sjcl.js');
var fs = require('fs'),
readline = require('readline'),
stream = require('stream');
var instream = fs.createReadStream('data');
var outstream = new stream;
outstream.readable = true;
outstream.writable = true;
var rl = readline.createInterface({
input: instream,
output: outstream,
terminal: false
});
rl.on('line', function(line) {
var cred = line.toLowerCase()+line;
var salt = sjcl.codec.utf8String.toBits(cred);
var id = sjcl.misc.scrypt(cred,salt,2048,8,1,32);
var ret = sjcl.codec.hex.fromBits(id);
console.log(ret+":"+line);
});
它可以工作,但这非常慢(10 行/秒)。有什么方法可以加快这个过程吗?