♻ Rewrite decrypt transform

This commit is contained in:
C-3PO 2018-07-05 11:39:39 +02:00
parent 8755fda1e3
commit 7cb458dfc5
Signed by: c3po
GPG key ID: 62993C4BB4D86F24

View file

@ -3,25 +3,12 @@ import getDecryptor from '../decryption/decryptChunk';
export default function decryptTransform(decryptionKeys: [number, number, number]): stream.Transform { export default function decryptTransform(decryptionKeys: [number, number, number]): stream.Transform {
const decryptor = getDecryptor(decryptionKeys); const decryptor = getDecryptor(decryptionKeys);
const transform = new stream.Transform(); const transform = new stream.Transform({
//TODO: we need to set transform._transform = (chunk) => { return chunk; } transform(chunk, encoding, callback) {
transform._transform = (chunk, encoding, callback) => { const decryptedChunk = decryptor(chunk);
const decryptedChunk = decryptor(chunk); callback(undefined, decryptedChunk);
callback(undefined, decryptedChunk); },
}; });
/*transform.on('readable', () => {
const encryptedChunk = transform.read();
if (encryptedChunk === null) {
transform.end();
return;
}
const decryptedChunk = decryptor(encryptedChunk);
transform.write(decryptedChunk);
});*/
return transform; return transform;
} }