Front end of the Slack clone application.

streamCipher.js 659B

12345678910111213141516171819202122232425262728
  1. var aes = require('./aes')
  2. var Buffer = require('safe-buffer').Buffer
  3. var Transform = require('cipher-base')
  4. var inherits = require('inherits')
  5. function StreamCipher (mode, key, iv, decrypt) {
  6. Transform.call(this)
  7. this._cipher = new aes.AES(key)
  8. this._prev = Buffer.from(iv)
  9. this._cache = Buffer.allocUnsafe(0)
  10. this._secCache = Buffer.allocUnsafe(0)
  11. this._decrypt = decrypt
  12. this._mode = mode
  13. }
  14. inherits(StreamCipher, Transform)
  15. StreamCipher.prototype._update = function (chunk) {
  16. return this._mode.encrypt(this, chunk, this._decrypt)
  17. }
  18. StreamCipher.prototype._final = function () {
  19. this._cipher.scrub()
  20. }
  21. module.exports = StreamCipher