[Pkg-javascript-commits] [node-browserify-aes] 78/92: pull out cipher-base

Bastien Roucariès rouca at moszumanska.debian.org
Sun Jun 4 09:35:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-browserify-aes.

commit e9c7a5b4b21fa6a4dc934ac874c4ffcef7b57c39
Author: Calvin Metcalf <calvin.metcalf at gmail.com>
Date:   Sat Sep 26 17:05:23 2015 -0400

    pull out cipher-base
---
 authCipher.js   |  2 +-
 cipherBase.js   | 54 ------------------------------------------------------
 decrypter.js    |  2 +-
 encrypter.js    |  2 +-
 package.json    |  1 +
 streamCipher.js |  2 +-
 6 files changed, 5 insertions(+), 58 deletions(-)

diff --git a/authCipher.js b/authCipher.js
index 802156c..1107a01 100644
--- a/authCipher.js
+++ b/authCipher.js
@@ -1,5 +1,5 @@
 var aes = require('./aes')
-var Transform = require('./cipherBase')
+var Transform = require('cipher-base')
 var inherits = require('inherits')
 var GHASH = require('./ghash')
 var xor = require('buffer-xor')
diff --git a/cipherBase.js b/cipherBase.js
deleted file mode 100644
index ad828d9..0000000
--- a/cipherBase.js
+++ /dev/null
@@ -1,54 +0,0 @@
-var Transform = require('stream').Transform
-var inherits = require('inherits')
-var StringDecoder = require('string_decoder').StringDecoder
-module.exports = CipherBase
-inherits(CipherBase, Transform)
-function CipherBase () {
-  Transform.call(this)
-  this._decoder = null
-  this._encoding = null
-}
-CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
-  if (typeof data === 'string') {
-    data = new Buffer(data, inputEnc)
-  }
-  var outData = this._update(data)
-  if (outputEnc) {
-    outData = this._toString(outData, outputEnc)
-  }
-  return outData
-}
-CipherBase.prototype._transform = function (data, _, next) {
-  this.push(this._update(data))
-  next()
-}
-CipherBase.prototype._flush = function (next) {
-  try {
-    this.push(this._final())
-  } catch(e) {
-    return next(e)
-  }
-  next()
-}
-CipherBase.prototype.final = function (outputEnc) {
-  var outData = this._final() || new Buffer('')
-  if (outputEnc) {
-    outData = this._toString(outData, outputEnc, true)
-  }
-  return outData
-}
-
-CipherBase.prototype._toString = function (value, enc, final) {
-  if (!this._decoder) {
-    this._decoder = new StringDecoder(enc)
-    this._encoding = enc
-  }
-  if (this._encoding !== enc) {
-    throw new Error('can\'t switch encodings')
-  }
-  var out = this._decoder.write(value)
-  if (final) {
-    out += this._decoder.end()
-  }
-  return out
-}
diff --git a/decrypter.js b/decrypter.js
index 983c218..1a02d5b 100644
--- a/decrypter.js
+++ b/decrypter.js
@@ -1,5 +1,5 @@
 var aes = require('./aes')
-var Transform = require('./cipherBase')
+var Transform = require('cipher-base')
 var inherits = require('inherits')
 var modes = require('./modes')
 var StreamCipher = require('./streamCipher')
diff --git a/encrypter.js b/encrypter.js
index a74e257..de0fc8b 100644
--- a/encrypter.js
+++ b/encrypter.js
@@ -1,5 +1,5 @@
 var aes = require('./aes')
-var Transform = require('./cipherBase')
+var Transform = require('cipher-base')
 var inherits = require('inherits')
 var modes = require('./modes')
 var ebtk = require('./EVP_BytesToKey')
diff --git a/package.json b/package.json
index 38d0937..2b7c98d 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
   "homepage": "https://github.com/crypto-browserify/browserify-aes",
   "dependencies": {
     "buffer-xor": "^1.0.2",
+    "cipher-base": "^1.0.0",
     "create-hash": "^1.1.0",
     "inherits": "^2.0.1"
   },
diff --git a/streamCipher.js b/streamCipher.js
index 2e0fb88..a55c762 100644
--- a/streamCipher.js
+++ b/streamCipher.js
@@ -1,5 +1,5 @@
 var aes = require('./aes')
-var Transform = require('./cipherBase')
+var Transform = require('cipher-base')
 var inherits = require('inherits')
 
 inherits(StreamCipher, Transform)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browserify-aes.git



More information about the Pkg-javascript-commits mailing list