Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browserify-aes

Package Overview
Dependencies
Maintainers
5
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserify-aes - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.npmignore

2

authCipher.js

@@ -5,3 +5,3 @@ var aes = require('./aes')

var GHASH = require('./ghash')
var xor = require('./xor')
var xor = require('buffer-xor')
inherits(StreamCipher, Transform)

@@ -8,0 +8,0 @@ module.exports = StreamCipher

@@ -8,2 +8,3 @@ var Transform = require('stream').Transform

Transform.call(this)
this._base64Cache = new Buffer('')
}

@@ -16,3 +17,3 @@ CipherBase.prototype.update = function (data, inputEnc, outputEnc) {

if (outputEnc) {
outData = outData.toString(outputEnc)
outData = this._toString(outData, outputEnc)
}

@@ -36,5 +37,33 @@ return outData

if (outputEnc) {
outData = outData.toString(outputEnc)
outData = this._toString(outData, outputEnc, true)
}
return outData
}
CipherBase.prototype._toString = function (value, enc, final) {
if (enc !== 'base64') {
return value.toString(enc)
}
this._base64Cache = Buffer.concat([this._base64Cache, value])
var out
if (final) {
out = this._base64Cache
this._base64Cache = null
return out.toString('base64')
}
var len = this._base64Cache.length
var overhang = len % 3
if (!overhang) {
out = this._base64Cache
this._base64Cache = new Buffer('')
return out.toString('base64')
}
var newLen = len - overhang
if (!newLen) {
return ''
}
out = this._base64Cache.slice(0, newLen)
this._base64Cache = this._base64Cache.slice(-overhang)
return out.toString('base64')
}

@@ -1,12 +0,17 @@

var xor = require('../xor')
var xor = require('buffer-xor')
exports.encrypt = function (self, block) {
var data = xor(block, self._prev)
self._prev = self._cipher.encryptBlock(data)
return self._prev
}
exports.decrypt = function (self, block) {
var pad = self._prev
self._prev = block
var out = self._cipher.decryptBlock(block)
return xor(out, pad)
}

@@ -1,5 +0,7 @@

var xor = require('../xor')
var xor = require('buffer-xor')
exports.encrypt = function (self, data, decrypt) {
var out = new Buffer('')
var len
while (data.length) {

@@ -10,2 +12,3 @@ if (self._cache.length === 0) {

}
if (self._cache.length <= data.length) {

@@ -20,2 +23,3 @@ len = self._cache.length

}
return out

@@ -22,0 +26,0 @@ }

@@ -1,15 +0,3 @@

var xor = require('../xor')
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)
}
var xor = require('buffer-xor')
function incr32 (iv) {

@@ -29,1 +17,16 @@ var len = iv.length

}
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)
}

@@ -1,2 +0,3 @@

var xor = require('../xor')
var xor = require('buffer-xor')
function getBlock (self) {

@@ -6,2 +7,3 @@ self._prev = self._cipher.encryptBlock(self._prev)

}
exports.encrypt = function (self, chunk) {

@@ -11,2 +13,3 @@ while (self._cache.length < chunk.length) {

}
var pad = self._cache.slice(0, chunk.length)

@@ -13,0 +16,0 @@ self._cache = self._cache.slice(chunk.length)

{
"name": "browserify-aes",
"version": "1.0.1",
"version": "1.0.2",
"description": "aes, for browserify",

@@ -29,2 +29,3 @@ "browser": "browser.js",

"dependencies": {
"buffer-xor": "^1.0.2",
"create-hash": "^1.1.0",

@@ -31,0 +32,0 @@ "inherits": "^2.0.1"

@@ -503,1 +503,31 @@ var test = require('tape')

})
test('correctly handle incremental base64 output', function (t) {
t.plan(2)
var encoding = 'base64'
function encrypt (data, key, algorithm) {
algorithm = algorithm || 'aes256'
var cipher = crypto.createCipher(algorithm, key)
var part1 = cipher.update(data, 'utf8', encoding)
var part2 = cipher.final(encoding)
return part1 + part2
}
function encryptNode (data, key, algorithm) {
algorithm = algorithm || 'aes256'
var cipher = _crypto.createCipher(algorithm, key)
var part1 = cipher.update(data, 'utf8', encoding)
var part2 = cipher.final(encoding)
return part1 + part2
}
function decrypt (data, key, algorithm) {
algorithm = algorithm || 'aes256'
var decipher = crypto.createDecipher(algorithm, key)
return decipher.update(data, encoding, 'utf8') + decipher.final('utf8')
}
var key = 'this is a very secure key'
var data = 'The quick brown fox jumps over the lazy dog.'
var encrypted = encrypt(data, key)
t.equals(encrypted, encryptNode(data, key), 'encrypt correctly')
var decrypted = decrypt(encrypted, key)
t.equals(data, decrypted, 'round trips')
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc