{"_id":"crypto-hash","_rev":"2954828","name":"crypto-hash","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","dist-tags":{"latest":"2.0.1"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2023-04-27T03:55:22.000Z","created":"2018-03-07T17:31:29.262Z","2.0.1":"2021-12-02T14:20:40.049Z","2.0.0":"2021-10-14T06:22:51.969Z","1.3.0":"2020-08-12T13:07:11.939Z","1.2.2":"2019-07-11T08:28:40.923Z","1.2.1":"2019-05-19T16:29:19.484Z","1.2.0":"2019-05-03T07:14:03.604Z","1.1.0":"2019-04-09T19:49:39.344Z","1.0.0":"2018-11-08T17:47:34.869Z","0.1.0":"2018-03-07T17:31:29.262Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"versions":{"2.0.1":{"name":"crypto-hash","version":"2.0.1","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"node":"./index.js","default":"./browser.js"},"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js && tsd"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^4.2.0","ava":"^3.15.0","hash.js":"^1.1.7","karmatic":"2.1.0","tsd":"^0.18.0","xo":"^0.45.0"},"types":"./index.d.ts","gitHead":"fbca8a21ce5a672ae3b55cc33ca30661f99c0cbe","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@2.0.1","_nodeVersion":"12.22.1","_npmVersion":"8.1.0","dist":{"shasum":"46c3732e65a078ea06b8b4ae686db41216f81213","size":3972,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-2.0.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_2.0.1_1638454839874_0.8705240665803382"},"_hasShrinkwrap":false,"publish_time":1638454840049,"_cnpm_publish_time":1638454840049,"_cnpmcore_publish_time":"2021-12-16T15:40:42.126Z"},"2.0.0":{"name":"crypto-hash","version":"2.0.0","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"node":"./index.js","default":"./browser.js"},"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js && tsd"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^4.2.0","ava":"^3.15.0","hash.js":"^1.1.7","karmatic":"2.1.0","tsd":"^0.18.0","xo":"^0.45.0"},"gitHead":"fbc067f3559f4bf8ac67b2c8355ff7e0102b68c4","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@2.0.0","_nodeVersion":"14.17.5","_npmVersion":"7.20.3","dist":{"shasum":"5cd5ac64c8504ad30e4ba03aacbd283b6160945c","size":3941,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-2.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_2.0.0_1634192571714_0.5303370369784173"},"_hasShrinkwrap":false,"publish_time":1634192571969,"_cnpm_publish_time":1634192571969,"_cnpmcore_publish_time":"2021-12-16T15:40:42.407Z"},"1.3.0":{"name":"crypto-hash","version":"1.3.0","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js && tsd"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^0.15.0","ava":"^1.4.1","hash.js":"^1.1.5","karmatic":"1.0.7","tsd":"^0.7.2","xo":"^0.24.0"},"browser":"browser.js","xo":{"rules":{"import/no-unresolved":"off"}},"gitHead":"6daa51e92d20a709494237cf51ac944efcc516c6","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@1.3.0","_nodeVersion":"14.5.0","_npmVersion":"6.14.7","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"b402cb08f4529e9f4f09346c3e275942f845e247","size":3793,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-1.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-1.3.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_1.3.0_1597237631787_0.748331260715555"},"_hasShrinkwrap":false,"publish_time":1597237631939,"_cnpm_publish_time":1597237631939,"_cnpmcore_publish_time":"2021-12-16T15:40:42.592Z"},"1.2.2":{"name":"crypto-hash","version":"1.2.2","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js && tsd"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^0.15.0","ava":"^1.4.1","hash.js":"^1.1.5","karmatic":"1.0.7","tsd":"^0.7.2","xo":"^0.24.0"},"browser":"browser.js","xo":{"rules":{"import/no-unresolved":"off"}},"gitHead":"57ce6aa649be7cff6cc551deba6e0a00ed0019c3","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@1.2.2","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"7ccdbae8a89907d3774f9c7769798b9d3af2cc4d","size":3750,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-1.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-1.2.2.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_1.2.2_1562833720810_0.578402970781388"},"_hasShrinkwrap":false,"publish_time":1562833720923,"_cnpm_publish_time":1562833720923,"_cnpmcore_publish_time":"2021-12-16T15:40:42.834Z"},"1.2.1":{"name":"crypto-hash","version":"1.2.1","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js && tsd"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^0.15.0","ava":"^1.4.1","hash.js":"^1.1.5","karmatic":"1.0.7","tsd":"^0.7.2","xo":"^0.24.0"},"browser":"browser.js","xo":{"rules":{"import/no-unresolved":"off"}},"gitHead":"70b67c81e46b966e09f5cdfc0daca9a830178538","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@1.2.1","_nodeVersion":"8.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"b7fbca0c9d749b8ae8f3ea44dd66eb11f3554165","size":3832,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-1.2.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_1.2.1_1558283359383_0.15425359048044762"},"_hasShrinkwrap":false,"publish_time":1558283359484,"_cnpm_publish_time":1558283359484,"_cnpmcore_publish_time":"2021-12-16T15:40:43.083Z"},"1.2.0":{"name":"crypto-hash","version":"1.2.0","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js && tsd"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^0.15.0","ava":"^1.4.1","hash.js":"^1.1.5","karmatic":"1.0.7","tsd":"^0.7.2","xo":"^0.24.0"},"browser":"browser.js","xo":{"rules":{"import/no-unresolved":"off"}},"gitHead":"fc519ea9ca9660e6d7ee3c762c24719f348bf925","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@1.2.0","_nodeVersion":"8.16.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"904acc24074ab653de752e54e1206a2a5f11aab4","size":3827,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-1.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_1.2.0_1556867643464_0.4432402832226292"},"_hasShrinkwrap":false,"publish_time":1556867643604,"_cnpm_publish_time":1556867643604,"_cnpmcore_publish_time":"2021-12-16T15:40:43.289Z"},"1.1.0":{"name":"crypto-hash","version":"1.1.0","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js && tsd"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^0.15.0","ava":"^1.4.1","hash.js":"^1.1.5","karmatic":"1.0.7","tsd":"^0.7.2","xo":"^0.24.0"},"browser":"browser.js","gitHead":"926223f87dcf01dd48cdcba1f16a280f13012351","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@1.1.0","_npmVersion":"6.4.1","_nodeVersion":"10.15.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"9d85c3947ded64763721f8054e42834ecce68c8d","size":2971,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_1.1.0_1554839379221_0.3126910225045041"},"_hasShrinkwrap":false,"publish_time":1554839379344,"_cnpm_publish_time":1554839379344,"_cnpmcore_publish_time":"2021-12-16T15:40:43.519Z"},"1.0.0":{"name":"crypto-hash","version":"1.0.0","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^0.13.0","ava":"^0.25.0","hash.js":"^1.1.5","karmatic":"1.0.6","xo":"^0.23.0"},"browser":"browser.js","gitHead":"ee1e238391fadec94e0e4ba5cc043bcd1ad2f5e6","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"cb141377ceb1606c3737086e59bbc4921a3c3358","size":2733,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_1.0.0_1541699254729_0.0316782670657898"},"_hasShrinkwrap":false,"publish_time":1541699254869,"_cnpm_publish_time":1541699254869,"_cnpmcore_publish_time":"2021-12-16T15:40:43.868Z"},"0.1.0":{"name":"crypto-hash","version":"0.1.0","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava test.js && karmatic test-browser.js"},"files":["index.js","browser.js"],"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^0.7.0","ava":"*","hash.js":"^1.1.3","karmatic":"^1.0.6","xo":"*"},"browser":"browser.js","gitHead":"cf7169d26397c215f17f7ac3467187455be3ed07","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_id":"crypto-hash@0.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.9.4","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"98651f63d24fc52bc2129f6be33a3e9b860e2cd5","size":2556,"noattachment":false,"key":"/crypto-hash/-/crypto-hash-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/crypto-hash/download/crypto-hash-0.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_0.1.0_1520443889208_0.24843303252529347"},"_hasShrinkwrap":false,"publish_time":1520443889262,"_cnpm_publish_time":1520443889262,"_cnpmcore_publish_time":"2021-12-16T15:40:44.089Z"}},"readme":"# crypto-hash\n\n> Tiny hashing module that uses the native crypto API in Node.js and the browser\n\nUseful when you want the same hashing API in all environments. My cat calls it *isomorphic*.\n\nIn Node.js it uses [`node:crypto`](https://nodejs.org/api/crypto.html#crypto_class_hash), while in the browser it uses [`window.crypto`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest).\n\nThe browser version is only ~300 bytes minified & gzipped.\n\nWhen used in the browser, it must be in a [secure context (HTTPS)](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle).\n\nThis package is for modern browsers. Internet Explorer is not supported.\n\n## Install\n\n```sh\nnpm install crypto-hash\n```\n\n## Usage\n\n```js\nimport {sha256} from 'crypto-hash';\n\nconsole.log(await sha256('????'));\n//=> '36bf255468003165652fe978eaaa8898e191664028475f83f506dabd95298efc'\n```\n\n## API\n\n### sha1(input, options?)\n### sha256(input, options?)\n### sha384(input, options?)\n### sha512(input, options?)\n\nReturns a `Promise<string>` with a Hex-encoded hash.\n\n*In Node.js, the operation is executed using [`worker_threads`](https://nodejs.org/api/worker_threads.html). A thread is lazily spawned on the first operation and lives until the end of the program execution. It's `unref`ed, so it won't keep the process alive.*\n\n[SHA-1 is insecure](https://stackoverflow.com/a/38045085/64949) and should not be used for anything sensitive.\n\n#### input\n\nType: `string` [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) [`ArrayBufferView`](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView)\n\n#### options\n\nType: `object`\n\n##### outputFormat\n\nType: `string`\\\nValues: `'hex' | 'buffer'`\\\nDefault: `'hex'`\n\nSetting this to `buffer` makes it return an `ArrayBuffer` instead of a `string`.\n\n## Related\n\n- [hasha](https://github.com/sindresorhus/hasha) - Hashing in Node.js made simple\n","_attachments":{},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"license":"MIT"}