3.0.0 • Published 6 months ago

crypto-hash v3.0.0

Weekly downloads
23,302
License
MIT
Repository
github
Last release
6 months ago

crypto-hash

Tiny hashing module that uses the native crypto API in Node.js and the browser

Useful when you want the same hashing API in all environments. My cat calls it isomorphic.

In Node.js it uses node:crypto, while in the browser it uses window.crypto.

The browser version is only ~300 bytes minified & gzipped.

When used in the browser, it must be in a secure context (HTTPS).

This package is for modern browsers. Internet Explorer is not supported.

Install

npm install crypto-hash

Usage

import {sha256} from 'crypto-hash';

console.log(await sha256('🦄'));
//=> '36bf255468003165652fe978eaaa8898e191664028475f83f506dabd95298efc'

API

sha1(input, options?)

sha256(input, options?)

sha384(input, options?)

sha512(input, options?)

Returns a Promise<string> with a Hex-encoded hash.

In Node.js, 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.

SHA-1 is insecure and should not be used for anything sensitive.

input

Type: string ArrayBuffer ArrayBufferView

options

Type: object

outputFormat

Type: string\ Values: 'hex' | 'buffer'\ Default: 'hex'

Setting this to buffer makes it return an ArrayBuffer instead of a string.

Related

  • hasha - Hashing in Node.js made simple
@safecoins/web3@phantasia/metaplex-jssolanaapireact-native-project-serum-anchor@infinitebrahmanuniverse/nolb-crypt@keval6706/commongolanasindresorhus.js@saberhq/anchor@safecoin/anchor@safely-project/anchor@safely-project/safely-tsreprehenderitlaborumreprehenderitmaioressha-anything@solarti/anchor@solareum/solana-web3.js@solbank-staking/onchain-program-sdk@solbank/onchain-program-sdk@solbank/staking-onchain-program-sdk@solcial.io/anchor-fork@solanambs/anchorporrobeatae@remitano-anhdt/metaplex-js@renec-foundation/metaplex-js@streamplace/cards@thoughtindustries/helium-server@types/crypto-hash@wum.bo/anchor@wum.bo/metaplex-oyster-common@synthetify/anchortest-anchor@staratlas/anchorsuntblanditiis@switchboard-xyz/anchor@drincs/pixi-vmeb-utilse4-metaplex-jsearumasperioresgraphony-clientgraphony-coregraphony-polka@epicfaace/anchor@everything-registry/sub-chunk-1416@exodus/project-serum-anchormedia-query-splitting-pluginmintavibe_cache_manager_microserviceleparfumeksy-metaplex-js-oneipaddrhashiobroker.vis-shellyinventoreofficia@exzo/web3oyster-commonoyster-common-sotatek@fjedi/graphql-react-components@fluidchains/metaplex-js@fora/react-native-anchorninja-canvashelperanchor-rnanchor-v24@vovacodes/anchorvelas-solana-web3architectoexpeditaautquae@arsonar/common@araviel/anchorainsley-loaderallpasstrustversionable@uttacoin/metaplex.js@zetamarkets/anchor@velas/account-rn-sdk@velas/react-native-account@velas/solana-web3@velas/web3accusantiumsit@heavy-duty/anchor@gigmade/file-loader@gigmade/msm-nodes@holaplex/js@hvrlk/solana@gambalabs/apollo@gemachain/web3.js@friktion-labs/anchor@frahman5/anchor@dgrlabs/metaplex-common@benzene/extra@benzene/persisted@betdex/anchorws-react-base-components@bn-digital/graphql-client@castlefinance/anchor@burnt/common@kenny4444/metaplex-js@junglebet/apollo-client@j0nnyboi/anchor@j0nnyboi/common@kryptonxyz/anchor@dainocreation/web3.js
3.0.0

6 months ago

2.0.1

2 years ago

2.0.0

3 years ago

1.3.0

4 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.1.0

6 years ago