aswi2020vldc-gitlab/templetes/node_modules/browserify-aes/modes/ofb.js @ 143404cb
1 | 3a515b92 | cagy | var xor = require('buffer-xor') |
---|---|---|---|
2 | |||
3 | function getBlock (self) { |
||
4 | self._prev = self._cipher.encryptBlock(self._prev) |
||
5 | return self._prev |
||
6 | }
|
||
7 | |||
8 | exports.encrypt = function (self, chunk) { |
||
9 | while (self._cache.length < chunk.length) { |
||
10 | self._cache = Buffer.concat([self._cache, getBlock(self)]) |
||
11 | }
|
||
12 | |||
13 | var pad = self._cache.slice(0, chunk.length) |
||
14 | self._cache = self._cache.slice(chunk.length) |
||
15 | return xor(chunk, pad) |
||
16 | }
|