aes-cbc-partial-decrypt
In CBC mode, the only thing needed to decrypt a specific block, is the ciphertext, key and previous ciphertext (to use as IV).

This library takes advantage of that, and implements partial decryption for AES-CBC with 128, 192 or 256 key length. Although other algorithms should be possible to implement as well.
It will return a stream that can be read, and will emit the resource decrypted from byte start
to byte end
specified.
How to use
var partialDecryptStream = require('cbc-partial-decrypt')
var opts = {
mode: 'aes-cbc-256',
keyLength: 256,
password: 'password',
iv: 'd',
start: 0,
end: 250,
encrypted: function (opts) {
return fs.createReadStream('path', opts)
}
}
partialDecryptStream(opts).pipe(process.stdout)
Notes
Specify end byte
This library uses setAutoPadding(false)
on the internal crypto.createDecipheriv()
, so it is recommended to know the original size of the
resource, and use it as end
when reading until the end of the file, as the default padding
will be emitted as data as well, unless cut out.
Non-stream mode
The library only offers to return back a stream, but the method should work aswell done synchronously with a part of the resource. Happy to accept PR with this functionality.
Other algorithms
As CBC is the block mode, but not the algoritmh itself, it should also be possible to implement this method with different cryptographic algorithms. Happy to accept PR with this functionality.