Socket
Socket
Sign inDemoInstall

hasha

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hasha - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

21

index.js

@@ -7,6 +7,5 @@ 'use strict';

var hasha = module.exports = function (buf, opts) {
var hasha = module.exports = function (input, opts) {
opts = opts || {};
var inputEncoding = typeof buf === 'string' ? 'utf8' : undefined;
var outputEncoding = opts.encoding || 'hex';

@@ -18,6 +17,16 @@

return crypto
.createHash(opts.algorithm || 'sha512')
.update(buf, inputEncoding)
.digest(outputEncoding);
var hash = crypto.createHash(opts.algorithm || 'sha512');
var update = function (buf) {
var inputEncoding = typeof buf === 'string' ? 'utf8' : undefined;
hash.update(buf, inputEncoding);
};
if (Array.isArray(input)) {
input.forEach(update);
} else {
update(input);
}
return hash.digest(outputEncoding);
};

@@ -24,0 +33,0 @@

{
"name": "hasha",
"version": "2.1.0",
"version": "2.2.0",
"description": "Hashing made simple. Get the hash of a buffer/string/stream/file.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -64,3 +64,3 @@ <h1 align="center">

Type: `buffer`, `string`
Type: `buffer`, `string`, `array` of `string`|`buffer`

@@ -71,2 +71,4 @@ Buffer you want to hash.

Pass an array instead of concatenating strings and/or buffers. The output is the same, but arrays do not incur the overhead of concatenation.
#### options

@@ -73,0 +75,0 @@

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