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.

17 lines
342 B

4 years ago
  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. }