{"id":25925307,"url":"https://github.com/umamiappearance/shaobj","last_synced_at":"2026-05-13T23:30:58.544Z","repository":{"id":65174417,"uuid":"585113736","full_name":"UmamiAppearance/SHAObj","owner":"UmamiAppearance","description":"JavaScript implementation of SHA-(1/256/384/512) checksum calculation for the browser and node.js. It uses the global SubtleCrypto interface (Web Crypto API). Multiple representations of the message digest are available (e.g. hexadecimal, base32, base64, ...)","archived":false,"fork":false,"pushed_at":"2023-07-16T21:34:50.000Z","size":308,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T06:06:53.693Z","etag":null,"topics":["browser","crypto","nodejs","sha-1","sha-256","sha-384","sha-512","shasum","subtlecrypto"],"latest_commit_sha":null,"homepage":"","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/UmamiAppearance.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-04T10:57:52.000Z","updated_at":"2023-03-12T04:38:18.000Z","dependencies_parsed_at":"2024-10-13T05:10:54.576Z","dependency_job_id":null,"html_url":"https://github.com/UmamiAppearance/SHAObj","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":"0.15000000000000002","last_synced_commit":"81bc79704dbed8fece967cd5555fa3b291128cc2"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/UmamiAppearance/SHAObj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UmamiAppearance%2FSHAObj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UmamiAppearance%2FSHAObj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UmamiAppearance%2FSHAObj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UmamiAppearance%2FSHAObj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UmamiAppearance","download_url":"https://codeload.github.com/UmamiAppearance/SHAObj/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UmamiAppearance%2FSHAObj/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266774780,"owners_count":23982247,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","nodejs","sha-1","sha-256","sha-384","sha-512","shasum","subtlecrypto"],"created_at":"2025-03-03T18:47:54.039Z","updated_at":"2025-10-28T01:04:02.327Z","avatar_url":"https://github.com/UmamiAppearance.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SHAObj\n\n[![License](https://img.shields.io/github/license/UmamiAppearance/SHAObj?color=009911\u0026style=for-the-badge)](./LICENSE)\n[![npm](https://img.shields.io/npm/v/sha-obj?color=%23009911\u0026style=for-the-badge)](https://www.npmjs.com/package/sha-obj)\n\n\n**SHAObj** creates a SHA-(1/256/384/512) object. It is very closely related to [pythons hashlib](https://docs.python.org/3/library/hashlib.html) in its methods and features. It provides an easy access to the ``Crypto.subtle`` method provided by modern browsers and node.js.  \n  \nOptionally it possible to get multiple different digest methods with a little help of [BaseEx](https://github.com/UmamiAppearance/BaseExJS). **BaseEx** also enables the feature to feed the Object with not just byte-like input but almost any type available in JavaScript. \n\n## Installation\n\n### GitHub\n```sh\ngit clone https://github.com/UmamiAppearance/SHAObj.git\n```\n\n### npm\n```sh\nnmp install sha-obj\n```\n\n## Builds\nYou can find builds in [dist](https://github.com/UmamiAppearance/SHAObj/tree/main/dist). Builds include versions with BaseEx build in and without the library. Two types for both kinds are available ([esm](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and [iife](https://developer.mozilla.org/en-US/docs/Glossary/IIFE)), plus a minified version of each.  \n  \nIf you want to build it by yourself run:\n\n```sh\nnpm run build\n``` \n\n#### Builds with BaseEx _(any desired input/several digest methods)_\n* [``sha-obj-bex.esm.js``](https://raw.githubusercontent.com/UmamiAppearance/SHAObj/main/dist/sha-obj-bex.esm.js)\n* [``sha-obj-bex.esm.min.js``](https://raw.githubusercontent.com/UmamiAppearance/SHAObj/main/dist/sha-obj-bex.esm.min.js)\n* [``sha-obj-bex.iife.js``](https://raw.githubusercontent.com/UmamiAppearance/SHAObj/main/dist/sha-obj-bex.iife.js)\n* [``sha-obj-bex.iife.min.js``](https://raw.githubusercontent.com/UmamiAppearance/SHAObj/main/dist/sha-obj-bex.iife.min.js)\n\n#### Builds without BaseEx _(byte like input/hexdigest)_\n* [``sha-obj.esm.js``](https://raw.githubusercontent.com/UmamiAppearance/SHAObj/main/dist/sha-obj.esm.js)\n* [``sha-obj.esm.min.js``](https://raw.githubusercontent.com/UmamiAppearance/SHAObj/main/dist/sha-obj.esm.min.js)\n* [``sha-obj.iife.js``](https://raw.githubusercontent.com/UmamiAppearance/SHAObj/main/dist/sha-obj.iife.js)\n* [``sha-obj.iife.min.js``](https://raw.githubusercontent.com/UmamiAppearance/SHAObj/main/dist/sha-obj.iife.min.js)\n\n\n## Usage\n\n### Importing\n\n#### node.js\n\n##### esm\n```js\nimport SHAObj from \"sha-obj\";\n```\n\n##### cjs\n```js\nconst SHAObj = require(\"sha-obj\");\n```\n\n\n#### Browser\n\n##### esm\n```js\nimport SHAObj from \"./path/sha-obj-bex.esm.min.js\";\n```\n\n##### esm from CDN (jsdelivr)\n```js\nimport SHAObj from \"https://cdn.jsdelivr.net/npm/sha-obj@latest/dist/sha-obj-bex.esm.min.js\"\n```\n\n##### iife script tag\n```html\n\u003cscript src=\"./path/sha-obj-bex.iife.min.js\"\u003e\u003c/script\u003e\n```\n\n##### iife script tag from CDN (jsdelivr)\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/sha-obj@latest/dist/sha-obj-bex.iife.min.js\"\u003e\u003c/script\u003e\n```\n\n### Creating an instance    \nThe constructor takes one argument for the ``algorithm`` which is set to ``SHA-256`` by default. Available options are:\n* ``SHA-1``\n* ``SHA-256``\n* ``SHA-384``\n* ``SHA-512``\n\nThere a two possible ways available to create an instance:\n\n#### the new operator\n```js\n// default, SHA-256\nconst sha256 = new SHAObj();\n\n// SHA-512\nconst sha512 = new SHAObj(\"SHA-512\");\n```\n\n#### the new method\n```js\n// default, SHA-256\nconst sha256 = await SHAObj.new();\n\n// SHA-512\nconst sha512 = await SHAObj.new(\"SHA-512\");\n```\n\nAs the method is asynchronous it allows you to associate a message in one go.\n```js\n// SHA-512\nconst sha512 = await SHAObj.new(\"SHA-512\", \"Hello World!\");\n```\n\n\n### Methods and Properties\n\n#### Static\n\n##### ``SHAObj.algorithmsAvailable()``\nA set containing the names of the hash algorithms that are available.\n\n##### ``SHAObj.algorithmsGuaranteed()``\nAdded for the sake of completeness in terms of compatibility with [pythons hashlib](https://docs.python.org/3/library/hashlib.html). Here it is simply pointing to [``algorithmsAvailable``](#shaobjalgorithmsavailable).\n\n##### ``SHAObj.new(algorithm, input)``\nAsynchronously creates a new instance. Optionally takes the ``algorithm`` as the first parameter, also an optional ``input`` which can be provided as the second parameter, and gets passed to the [``update``](#updateinput-replacefalse) method.\n\n##### ``SHAObj.baseEx`` _[object]_\nA [BaseEx Instance](https://github.com/UmamiAppearance/BaseExJS#available-converterscharsets) for the possibility to manually convert (byte) representations.\n\n#### Instance\n\n##### ``digestSize``  _[property]_\nThe size of the resulting hash in bytes.\n\n##### ``blockSize`` _[property]_\nThe internal block size of the hash algorithm in bytes.\n\n##### ``name`` _[property]_\nThe canonical name of this hash, always uppercase and always suitable as a parameter to create another hash of this type.\n\n##### ``update(input[, replace=false])``\nUpdate the hash object with almost any input. The input gets converted to a ``Uint8Array``. Unless ``replace`` is set to true, repeated calls are equivalent to a single call with the concatenation of all the arguments:  \n``shaObj.update(a)``; ``shaObj.update(b)`` is in many occasions equivalent to ``shaObj.update(a+b)``.  \n  \n_(Note: The process is a concatenation of bytes. Take as an exception for instance ``shaObj.update(1)``; ``shaObj.update(2)``, which is not the same as ``shaObj.update(1+2)``)_\n\n\n##### ``replace(input)``\nReplace the the hash object with fresh input (the same as ``update(input, true)``).\n\n##### ``digest()``\nReturn the digest of the data passed to the [``update``](#updateinput-replacefalse) method so far. This is an ``ArrayBuffer`` of size [``digestSize``](#digestsize-property).\n\n\n##### ``hexdigest()``\nLike [``digest``](#digest) except the digest is returned as a string of double length, containing only hexadecimal digits. This may be used (as one of many options) to exchange the value safely in non-binary environments.\n\n##### ``basedigest`` _[object]_\nProvides many different methods to covert the digest into different base representations. Take a look at the [live-examples](https://umamiappearance.github.io/SHAObj/examples/live-examples.html#base-representations), to see it in action.  \nEvery ``basedigest`` optionally takes additional [BaseEx Parameters](https://github.com/UmamiAppearance/BaseExJS#options).\n\n##### ``copy()``\nAsync method to return a copy/clone of the hash object. This can be used to efficiently compute the digests of data sharing a common initial substring.\n\n\n## Examples\n[Here](https://umamiappearance.github.io/SHAObj/examples/live-examples.html) you can find many live-examples. To get a better idea of a possible use case, take a look at the [Online SHA Checksum Calculator](https://umamiappearance.github.io/SHAObj/examples/calculator.html).\n\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n\nCopyright (c) 2023, UmamiAppearance\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumamiappearance%2Fshaobj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumamiappearance%2Fshaobj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumamiappearance%2Fshaobj/lists"}