Sha256: e34a4b5fb97d34008071dc50baf437ab73308974890831b34dcf47693458b6d8

Contents?: true

Size: 662 Bytes

Versions: 8

Compression:

Stored size: 662 Bytes

Contents

var xor = require('buffer-xor')

function incr32 (iv) {
  var len = iv.length
  var item
  while (len--) {
    item = iv.readUInt8(len)
    if (item === 255) {
      iv.writeUInt8(0, len)
    } else {
      item++
      iv.writeUInt8(item, len)
      break
    }
  }
}

function getBlock (self) {
  var out = self._cipher.encryptBlock(self._prev)
  incr32(self._prev)
  return out
}

exports.encrypt = function (self, chunk) {
  while (self._cache.length < chunk.length) {
    self._cache = Buffer.concat([self._cache, getBlock(self)])
  }
  var pad = self._cache.slice(0, chunk.length)
  self._cache = self._cache.slice(chunk.length)
  return xor(chunk, pad)
}

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
lanes-0.8.0 node_modules/browserify-aes/modes/ctr.js
minimum_viable_product-0.0.11 test/dummy/node_modules/browserify-aes/modes/ctr.js
brwy_rails-0.0.6 test/dummy/node_modules/browserify-aes/modes/ctr.js
brwy_rails-0.0.5 test/dummy/node_modules/browserify-aes/modes/ctr.js
brwy_rails-0.0.4 test/dummy/node_modules/browserify-aes/modes/ctr.js
brwy_rails-0.0.3 test/dummy/node_modules/browserify-aes/modes/ctr.js
brwy_rails-0.0.2 test/dummy/node_modules/browserify-aes/modes/ctr.js
brwy_rails-0.0.1 test/dummy/node_modules/browserify-aes/modes/ctr.js