{"id":13454954,"url":"https://github.com/sindresorhus/crypto-hash","last_synced_at":"2025-05-14T04:00:22.624Z","repository":{"id":44626880,"uuid":"124269570","full_name":"sindresorhus/crypto-hash","owner":"sindresorhus","description":"Tiny hashing module that uses the native crypto API in Node.js and the browser","archived":false,"fork":false,"pushed_at":"2025-01-24T06:30:42.000Z","size":33,"stargazers_count":639,"open_issues_count":2,"forks_count":27,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-07T17:22:00.688Z","etag":null,"topics":["browser","crypto","hash-functions","hashing","isomorphic","nodejs","npm-package","sha256"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2018-03-07T17:17:29.000Z","updated_at":"2025-05-05T14:45:45.000Z","dependencies_parsed_at":"2025-02-14T12:15:31.136Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/crypto-hash","commit_stats":{"total_commits":36,"total_committers":9,"mean_commits":4.0,"dds":0.2777777777777778,"last_synced_commit":"3f2e73e8427a7fecd1bd81cad18d4cc159463175"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fcrypto-hash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fcrypto-hash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fcrypto-hash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fcrypto-hash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/crypto-hash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253661598,"owners_count":21943959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","crypto","hash-functions","hashing","isomorphic","nodejs","npm-package","sha256"],"created_at":"2024-07-31T08:00:59.736Z","updated_at":"2025-05-14T04:00:22.556Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","JavaScript","Repository","包","目录"],"sub_categories":["Security","Crypto","安全","安全相关"],"readme":"# crypto-hash\n\n\u003e 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 \u0026 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//=\u003e '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\u003cstring\u003e` 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fcrypto-hash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fcrypto-hash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fcrypto-hash/lists"}