Socket
Socket
Sign inDemoInstall

sha.js

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sha.js - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

2

hash.js

@@ -20,3 +20,3 @@ var u = require('./util')

if(enc == null) return data.byteLength || data.length
if(enc == 'ascii') return data.length
if(enc == 'ascii' || enc == 'binary') return data.length
if(enc == 'hex') return data.length/2

@@ -23,0 +23,0 @@ if(enc == 'base64') return data.length/3

{
"name": "sha.js",
"description": "streaming sha1 hash in pure javascript",
"version": "1.2.2",
"version": "1.3.0",
"homepage": "https://github.com/dominictarr/sha.js",

@@ -6,0 +6,0 @@ "repository": {

@@ -30,2 +30,4 @@ var Sha1 = require('../sha1')

var base64 = new Sha1().update(toString(EMPTY, 'base64'), 'base64').digest('hex')
console.log('Binary:', JSON.stringify(toString(EMPTY, 'binary')))
var binary = new Sha1().update(toString(EMPTY, 'binary'), 'binary').digest('hex')
var buffer = new Sha1().update(EMPTY).digest('hex')

@@ -35,4 +37,5 @@ console.log(hex, base64, buffer)

t.equal(hex, buffer)
t.equal(hex, binary)
t.end()
})

@@ -23,3 +23,3 @@ exports.write = write

var l = (to - from)
if(enc === 'ascii') {
if(enc === 'ascii' || enc === 'binary') {
for( var i = 0; i < l; i++) {

@@ -58,2 +58,13 @@ buffer[start + i] = string.charCodeAt(i + from)

function toBinary (buf) {
var s = ''
var l = 'string' === typeof buf ? buf.length : buf.byteLength
var s = ''
for(var i = 0; i < l; i++) {
var char = buf.charCodeAt ? buf.charCodeAt(i) : buf[i]
s += String.fromCharCode(char)
}
return s
}
//always fill to the end!

@@ -69,3 +80,5 @@ function zeroFill(buf, from) {

return toHex(buf)
if('binary' == enc)
return toBinary(buf)
return bopsToString(buf, enc)
}
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