Sha256: df60f615a53a6c143b279892e3b4f8004d80ab925e738de4fc43a046281bd823

Contents?: true

Size: 917 Bytes

Versions: 35

Compression:

Stored size: 917 Bytes

Contents

var Buffer = require('safe-buffer').Buffer

function encryptByte (self, byteParam, decrypt) {
  var pad
  var i = -1
  var len = 8
  var out = 0
  var bit, value
  while (++i < len) {
    pad = self._cipher.encryptBlock(self._prev)
    bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
    value = pad[0] ^ bit
    out += ((value & 0x80) >> (i % 8))
    self._prev = shiftIn(self._prev, decrypt ? bit : value)
  }
  return out
}

function shiftIn (buffer, value) {
  var len = buffer.length
  var i = -1
  var out = Buffer.allocUnsafe(buffer.length)
  buffer = Buffer.concat([buffer, Buffer.from([value])])

  while (++i < len) {
    out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
  }

  return out
}

exports.encrypt = function (self, chunk, decrypt) {
  var len = chunk.length
  var out = Buffer.allocUnsafe(len)
  var i = -1

  while (++i < len) {
    out[i] = encryptByte(self, chunk[i], decrypt)
  }

  return out
}

Version data entries

35 entries across 34 versions & 12 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.18.0 test/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.18.2 test/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.16.1 test/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.15.2 test/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.18.4 test/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.18.1 test/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.14.0 test/dummy/node_modules/browserify-aes/modes/cfb1.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/browserify-aes/modes/cfb1.js
tang-0.2.1 spec/tang_app/node_modules/browserify-aes/modes/cfb1.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/browserify-aes/modes/cfb1.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/browserify-aes/modes/cfb1.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/browserify-aes/modes/cfb1.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/browserify-aes/modes/cfb1.js
tang-0.2.0 spec/tang_app/node_modules/browserify-aes/modes/cfb1.js
tang-0.1.0 spec/tang_app/node_modules/browserify-aes/modes/cfb1.js
tang-0.0.9 spec/tang_app/node_modules/browserify-aes/modes/cfb1.js
enju_library-0.3.8 spec/dummy/node_modules/browserify-aes/modes/cfb1.js
ilog-0.4.1 node_modules/browserify-aes/modes/cfb1.js