cbc.js 342 B

1234567891011121314151617
  1. var xor = require('buffer-xor')
  2. exports.encrypt = function (self, block) {
  3. var data = xor(block, self._prev)
  4. self._prev = self._cipher.encryptBlock(data)
  5. return self._prev
  6. }
  7. exports.decrypt = function (self, block) {
  8. var pad = self._prev
  9. self._prev = block
  10. var out = self._cipher.decryptBlock(block)
  11. return xor(out, pad)
  12. }