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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6528
54
121