universal-sha256-js
Advanced tools
Comparing version 1.0.3 to 2.0.0
{ | ||
"name": "universal-sha256-js", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "An ultra lightweight ~400b universal JavaScript SHA256 cryptographic hash function (Node.js + Browsers).", | ||
"scripts": { | ||
"prepare": "npm run prepare:jsdoc && npm run prepare:prettier", | ||
"prepare:jsdoc": "jsdoc-md", | ||
"prepare:prettier": "prettier --write readme.md", | ||
"test": "npm run test:eslint && npm run test:prettier && npm run test:api", | ||
"test:api": "coverage-node test/index.test.mjs", | ||
"test:eslint": "eslint .", | ||
"test:prettier": "prettier -c .", | ||
"eslint": "eslint .", | ||
"prettier": "prettier -c .", | ||
"prettier:readme": "prettier --write readme.md", | ||
"types": "tsc -p jsconfig.json", | ||
"tests": "coverage-node test/index.test.mjs", | ||
"test": "npm run eslint && npm run prettier && npm run types && npm run tests", | ||
"prepublishOnly": "npm test" | ||
@@ -34,7 +33,7 @@ }, | ||
"files": [ | ||
"index.js" | ||
"sha256.mjs" | ||
], | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": "./index.js" | ||
"./sha256.mjs": "./sha256.mjs" | ||
}, | ||
@@ -49,15 +48,10 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/node": "^18.13.0", | ||
"coverage-node": "^8.0.0", | ||
"eslint": "^8.25.0", | ||
"eslint-config-env": "^23.0.2", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-compat": "^4.0.2", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jsdoc": "^39.3.6", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jsdoc-md": "^11.0.2", | ||
"prettier": "^2.7.1", | ||
"test-director": "^10.0.0" | ||
"eslint": "^8.34.0", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
"prettier": "^2.8.4", | ||
"test-director": "^10.0.0", | ||
"typescript": "^4.9.5" | ||
} | ||
} |
# Universal-SHA256-js | ||
An ultra lightweight universal JavaScript SHA256 cryptographic hash function for Node.js and Browsers. | ||
A SHA256 cryptographic hash function that is compatible with Node.js, Deno, and web browsers, and is designed to be extremely lightweight. | ||
- <400 bytes _(minifeied + gzipped) to bundle_ | ||
## Setup | ||
# Setup | ||
Node.js | ||
@@ -13,55 +13,27 @@ ```shell | ||
Ways to require. | ||
Deno | ||
```js | ||
const sha256 = require('universal-sha256-js') | ||
import sha256 from "https://deno.land/x/sha256js/sha256.mjs"; | ||
``` | ||
Ways to import. | ||
## Support | ||
```js | ||
import sha256 from 'universal-sha256-js' | ||
``` | ||
# Support | ||
- Node.js `>16` | ||
- Browser `defaults, no IE 11` | ||
- Deno `^1.30.0` | ||
# API | ||
## Examples | ||
## function sha256 | ||
Usage `sha256` | ||
Universal sha256 message digest helper function. | ||
```js | ||
import sha256 from "universal-sha256-js/sha256.mjs"; | ||
| Parameter | Type | Description | | ||
| :-------- | :--------- | :------------------- | | ||
| `data` | Uint8Array | Binary data to hash. | | ||
const array = Uint8Array.from( | ||
Buffer.from("The quick brown fox jumped over the lazy dog") | ||
); | ||
sha256(array).then(console.log); | ||
``` | ||
**Returns:** Uint8Array — Message digest. | ||
### Examples | ||
_Ways to `import`._ | ||
> ```js | ||
> import sha256 from 'sha256-js' | ||
> ``` | ||
_Ways to `require`._ | ||
> ```js | ||
> const sha256 = require('sha256-js') | ||
> ``` | ||
_Usage `sha256` in node._ | ||
> ```js | ||
> const array = Uint8Array.from( | ||
> Buffer.from('The quick brown fox jumped over the lazy dog') | ||
> ) | ||
> | ||
> sha256(array).then(console.log) | ||
> ``` | ||
> | ||
> > The logged output is \[215, …, 146 ] | ||
> The logged output is \[215, …, 146 ] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7
2862
23
39