hasha alternatives and similar modules
Based on the "Miscellaneous" category.
Alternatively, view hasha alternatives based on common mentions on social networks and blogs.
-
Electron
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS -
cheerio
The fast, flexible, and elegant library for parsing and manipulating HTML and XML. -
jsdom
A JavaScript implementation of various web standards, for use with Node.js -
patch-package
Fix broken node modules instantly ๐๐ฝโโ๏ธ๐จ -
webworker-threads
Lightweight Web Worker API implementation with native threads -
mem
Memoize functions - an optimization technique used to speed up consecutive function calls by caching the result of calls with identical input -
dot-prop
Get, set, or delete a property from a nested object using a dot path -
basic-ftp
FTP client for Node.js, supports FTPS over TLS, passive mode over IPv6, async/await, and Typescript. -
schemapack
Create a schema object to encode/decode your JSON in to a compact byte buffer with no overhead. -
nar
node.js application archive - create self-contained binary like executable applications that are ready to ship and run -
stringify-object
Stringify an object/array like JSON.stringify just without all the double-quotes -
cashify
๐ธ Lightweight currency conversion library, successor of money.js -
node-video-lib
Node.js Video Library / MP4 & FLV parser / MP4 builder / HLS muxer -
resolve-from
Resolve the path of a module like require.resolve() but from a given path -
remote-git-tags
Get tags from a remote git repo. Using only JS. No git binary required.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of hasha or a related project?
README
Hashing made simple. Get the hash of a buffer/string/stream/file.
Convenience wrapper around the core crypto
Hash class with simpler API and better defaults.
Install
$ npm install hasha
Usage
const hasha = require('hasha');
hasha('unicorn');
//=> 'e233b19aabc7d5e53826fb734d1222f1f0444c3a3fc67ff4af370a66e7cadd2cb24009f1bc86f0bed12ca5fcb226145ad10fc5f650f6ef0959f8aadc5a594b27'
const hasha = require('hasha');
(async () => {
console.log(await hasha.async('unicorn'));
//=> 'e233b19aabc7d5e53826fb734d1222f1f0444c3a3fc67ff4af370a66e7cadd2cb24009f1bc86f0bed12ca5fcb226145ad10fc5f650f6ef0959f8aadc5a594b27'
})();
const hasha = require('hasha');
// Hash the process input and output the hash sum
process.stdin.pipe(hasha.stream()).pipe(process.stdout);
const hasha = require('hasha');
(async () => {
// Get the MD5 hash of an image
const hash = await hasha.fromFile('unicorn.png', {algorithm: 'md5'});
console.log(hash);
//=> '1abcb33beeb811dca15f0ac3e47b88d9'
})();
API
See the Node.js crypto
docs for more about hashing.
hasha(input, options?)
Returns a hash.
input
Type: Buffer | string | Array<Buffer | string>
Buffer you want to hash.
While strings are supported you should prefer buffers as they're faster to hash. Although if you already have a string you should not convert it to a buffer.
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
Type: object
encoding
Type: string
\
Default: 'hex'
\
Values: 'hex' | 'base64' | 'buffer' | 'latin1'
Encoding of the returned hash.
algorithm
Type: string
\
Default: 'sha512'
\
Values: 'md5' | 'sha1' | 'sha256' | 'sha512'
(Platform dependent)
The md5
algorithm is good for file revving, but you should never use md5
or sha1
for anything sensitive. They're insecure.
hasha.async(input, options?)
In Node.js 12 or later, the operation is executed using worker_threads
. A thread is lazily spawned on the first operation and lives until the end of the program execution. It's unrefed, so it won't keep the process alive.
Returns a hash asynchronously.
hasha.stream(options?)
Returns a hash transform stream.
hasha.fromStream(stream, options?)
Returns a Promise
for the calculated hash.
hasha.fromFile(filepath, options?)
In Node.js 12 or later, the operation is executed using worker_threads
. A thread is lazily spawned on the first operation and lives until the end of the program execution. It's unrefed, so it won't keep the process alive.
Returns a Promise
for the calculated file hash.
hasha.fromFileSync(filepath, options?)
Returns the calculated file hash.
Related
- hasha-cli - CLI for this module
- crypto-hash - Tiny hashing module that uses the native crypto API in Node.js and the browser
- hash-obj - Get the hash of an object
- md5-hex - Create a MD5 hash with hex encoding