{"_id":"@cao-mei-you-ren/crypto-hash","name":"@cao-mei-you-ren/crypto-hash","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"@cao-mei-you-ren/crypto-hash","version":"3.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"},"publishConfig":{"access":"public"},"private":false,"type":"module","exports":{"types":"./index.d.ts","import":"./index.js","require":"./dist/index.cjs","default":"./browser.js"},"engines":{"node":">=18"},"scripts":{"//test":"xo && ava test.js && karmatic test-browser.js && tsd","test":"xo && ava test.js && tsd","build":"tsup"},"keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"devDependencies":{"@sindresorhus/is":"^6.0.1","ava":"^5.3.1","hash.js":"^1.1.7","tsd":"^0.29.0","tsup":"^8.0.2","typescript":"^5.4.3","xo":"^0.56.0"},"_id":"@cao-mei-you-ren/crypto-hash@3.0.0","gitHead":"e7bb85e200f3eaac210f3584a6c03baba6d9280f","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"homepage":"https://github.com/sindresorhus/crypto-hash#readme","_nodeVersion":"20.10.0","_npmVersion":"10.5.0","dist":{"integrity":"sha512-wUGqtwFA6uqhwJvHY134ZreQ9eUQBc2h1qsWrCYu54SHEn5F9INTiodGzS+XLCtk8oB8HidZriEt6sz5geVkiw==","shasum":"791f82815b72c2febb4f0ba3da86507b03969252","tarball":"https://registry.npmjs.org/@cao-mei-you-ren/crypto-hash/-/crypto-hash-3.0.0.tgz","fileCount":9,"unpackedSize":16149,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICHfbZ+S27R7u9t5tgKcWpVXyBbKprl7n4H5OaeuYqPIAiEAtTlQ/F6/4RmKr+Cr3GX8GHl7/EsW3WNu/fk3dX4PeqM="}]},"_npmUser":{"name":"cao-mei-you-ren","email":"caomeiyouren@qq.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/crypto-hash_3.0.0_1719849242282_0.6516518721164322"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-01T15:54:01.797Z","3.0.0":"2024-07-01T15:54:02.418Z","modified":"2024-07-01T15:54:02.671Z"},"maintainers":[{"name":"cao-mei-you-ren","email":"caomeiyouren@qq.com"}],"description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","homepage":"https://github.com/sindresorhus/crypto-hash#readme","keywords":["crypto","hash","isomorphic","hashing","hasher","cryptography","sha1","sha256","sha384","sha512","browser"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/crypto-hash.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/sindresorhus/crypto-hash/issues"},"license":"MIT","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","readmeFilename":"readme.md"}