You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ofb.js 415B

12345678910111213141516
  1. var xor = require('buffer-xor')
  2. function getBlock (self) {
  3. self._prev = self._cipher.encryptBlock(self._prev)
  4. return self._prev
  5. }
  6. exports.encrypt = function (self, chunk) {
  7. while (self._cache.length < chunk.length) {
  8. self._cache = Buffer.concat([self._cache, getBlock(self)])
  9. }
  10. var pad = self._cache.slice(0, chunk.length)
  11. self._cache = self._cache.slice(chunk.length)
  12. return xor(chunk, pad)
  13. }