{"id":23814202,"url":"https://github.com/stuartpb/any_sha1","last_synced_at":"2026-06-07T16:31:01.651Z","repository":{"id":21499391,"uuid":"24818342","full_name":"stuartpb/any_sha1","owner":"stuartpb","description":"JavaScript functions for abstracting SHA1 implementations","archived":false,"fork":false,"pushed_at":"2014-10-28T19:25:55.000Z","size":152,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T05:34:04.576Z","etag":null,"topics":[],"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/stuartpb.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":null,"support":null}},"created_at":"2014-10-05T15:08:37.000Z","updated_at":"2020-05-27T20:34:25.000Z","dependencies_parsed_at":"2022-08-21T16:00:52.980Z","dependency_job_id":null,"html_url":"https://github.com/stuartpb/any_sha1","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fany_sha1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fany_sha1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fany_sha1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fany_sha1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stuartpb","download_url":"https://codeload.github.com/stuartpb/any_sha1/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239384641,"owners_count":19629509,"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":[],"created_at":"2025-01-02T03:46:49.313Z","updated_at":"2026-05-02T21:30:15.222Z","avatar_url":"https://github.com/stuartpb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# any_sha1\n\nThis package provides JavaScript functions for abstracting SHA-1\nimplementations, providing a uniform signature and interface.\n\nWhen `module` is defined, this function will require and use the `crypto`\nmodule to produce the SHA-1 hash.\n\nOtherwise, it will detect and use SHA-1 functions from the following projects,\nin order:\n\n- `require(\"crypto\")`, for NodeJS / browserify (based on the presence of\n  `module`)\n- [Rusha](https://github.com/srijs/rusha)\n- [Forge](https://github.com/digitalbazaar/forge#sha1)\n- [SJCL](https://github.com/bitwiseshiftleft/sjcl)\n- [jsSHA](https://github.com/Caligatio/jsSHA)\n- [Paul Johnston's hex_sha1 function](http://pajhome.org.uk/crypt/md5/)\n- [CryptoJS](https://code.google.com/p/crypto-js/)\n- [PolyCrypt](https://github.com/polycrypt/polycrypt)\n\n(Pull requests to add more implementations are welcome.)\n\n## any_sha1.from(opts)\n\nDetects for the presence of the projects listed above, and returns the first\nfunction from `opts` that matches a detected environment (or `null`, if no\nrecognized SHA-1 implementation was found).\n\nThe \"opts\" parameter is expected to come from one of the sets defined below,\nwhere the first level is the input encoding to hash (eg. 'utf8') and the\nsecond level is the output type (eg. 'bytes' for an array of byte values).\n\n## any_sha1.define(opts,[obj,[key,[chooser]]])\n\nDefines `key` (by default, `sha1`) in `obj` (by default, `window`) to the\nfunction in `opts` selected by `chooser` (by default, `any_sha1.from`).\n\nIf no appropriate SHA-1 function is found (`chooser(opts)` returns `null`),\nthis function will return / define a function that will attept to define the\nSHA-1 function when first called, allowing for a late-binding approach where\nthe appropriate SHA-1 implementation is introduced after this function is\ninvoked.\n\n## Input encodings: any_sha1.utf8\n\nOutput options under this encoding type treat extended characters in the given\nstring outside the ASCII set as their UTF-8 byte representations. (Due to the\nmodern ubiquity of the UTF-8 encoding, nowadays, this is usually what you\nwant: as such, for the moment, this is the only input encoding this package\nprovides.)\n\nFor SHA-1 functions that don't handle strings with character codes outside the\n0-255 range (pretty much all of them), the string will first be converted to\nUTF-8 via the [unescape-encodeURIComponent method][1].\n\n[1]: http://ecmanaut.blogspot.com/2006/07/encoding-decoding-utf8-in-javascript.html\n\n## Output options: any_sha1.utf8.bytes\n\nReturns the SHA-1 hash as an array of byte values.\n\n## Example usage\n\nTo define a default SHA-1 function for [hashblot][], allowing for late binding:\n\n```\nany_sha1.define(any_sha1.utf8.bytes, hashblot);\n```\n\n[hashblot]: https://github.com/stuartpb/hashblot\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartpb%2Fany_sha1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuartpb%2Fany_sha1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartpb%2Fany_sha1/lists"}