Socket
Socket
Sign inDemoInstall

cipher-base

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

8

index.js

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

Transform.call(this)
this.hashMode = typeof hashMode === 'string';
this.hashMode = typeof hashMode === 'string'
if (this.hashMode) {

@@ -34,3 +34,7 @@ this[hashMode] = this._finalOrDigest

try {
this.push(this._update(data))
if (this.hashMode) {
this._update(data)
} else {
this.push(this._update(data))
}
} catch (e) {

@@ -37,0 +41,0 @@ err = e

{
"name": "cipher-base",
"version": "1.0.0",
"version": "1.0.1",
"description": "abstract base class for crypto-streams",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -45,2 +45,27 @@ var test = require('tape')

})
test('hash mode as stream', function (t) {
inherits(Cipher, CipherBase)
function Cipher () {
CipherBase.call(this, 'finalName')
this._cache = []
}
Cipher.prototype._update = function (input) {
t.ok(Buffer.isBuffer(input))
this._cache.push(input)
}
Cipher.prototype._final = function () {
return Buffer.concat(this._cache)
}
var cipher = new Cipher()
cipher.on('error', function (e) {
t.notOk(e)
})
var utf8 = 'abc123abcd'
cipher.end(utf8, 'utf8')
var update = cipher.read().toString('base64')
var string = (new Buffer(update, 'base64')).toString()
t.equals(utf8, string)
t.end()
})
test('encodings', function (t) {

@@ -47,0 +72,0 @@ inherits(Cipher, CipherBase)

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc