@cryptography/sha256
Advanced tools
Comparing version 0.1.2 to 0.1.3
/** | ||
* Calculates sha256 hash from string | ||
*/ | ||
export default function sha256(message: string): string; | ||
declare function sha256(message: string): string; | ||
declare namespace sha256 { | ||
var stream: () => StreamInterface; | ||
var blockLength: number; | ||
var digestLength: number; | ||
} | ||
declare function sha256(message: string, out: 'array'): Uint32Array; | ||
declare namespace sha256 { | ||
var stream: () => StreamInterface; | ||
var blockLength: number; | ||
var digestLength: number; | ||
} | ||
interface StreamInterface { | ||
data: string; | ||
length: number; | ||
state: Uint32Array; | ||
update(data: string | Uint32Array): StreamInterface; | ||
digest(): string; | ||
digest(format: 'array'): Uint32Array; | ||
} | ||
export default sha256; |
{ | ||
"name": "@cryptography/sha256", | ||
"description": "https://github.com/js-cryptography/sha256", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Konstantin Darutkin", | ||
@@ -9,3 +9,3 @@ "scripts": { | ||
"lint": "eslint --ext .ts ./src", | ||
"build": "rm -rf dist/* && tsc --declaration && npm run minify", | ||
"build": "rm -rf dist/* && webpack --mode=production", | ||
"analyze": "npm run build -- --analyze", | ||
@@ -33,2 +33,3 @@ "test": "jest --coverage", | ||
"jest": "^24.9.0", | ||
"terser-webpack-plugin": "^2.2.3", | ||
"ts-jest": "^24.2.0", | ||
@@ -38,3 +39,3 @@ "ts-loader": "^6.2.1", | ||
"uglify-js": "^3.7.1", | ||
"webpack": "^4.40.2", | ||
"webpack": "^5.0.0-beta.9", | ||
"webpack-bundle-analyzer": "^3.6.0", | ||
@@ -41,0 +42,0 @@ "webpack-cli": "^3.3.9" |
# @cryptography/sha256 | ||
[![Bundlephobia](https://img.shields.io/bundlephobia/minzip/@cryptography/sha256)](https://bundlephobia.com/result?p=@cryptography/sha256@0.1.1) | ||
[![Bundlephobia](https://img.shields.io/bundlephobia/minzip/@cryptography/sha256)](https://bundlephobia.com/result?p=@cryptography/sha256@0.1.3) | ||
[![Coverage](https://img.shields.io/codecov/c/github/js-cryptography/sha256?token=617017dc35344eb6b4637420457746c8)](https://codecov.io/gh/js-cryptography/sha256) | ||
@@ -13,3 +13,3 @@ [![Travis CI](https://img.shields.io/travis/js-cryptography/sha256)](https://travis-ci.com/js-cryptography/sha256) | ||
* Typed | ||
* Tested | ||
* Tested` | ||
@@ -23,8 +23,8 @@ ## Setup | ||
yarn add @cryptography/sha256 | ||
``` | ||
```` | ||
## Usage | ||
This package is designed to be simple and lightweight. It is exported as single synchronous function. | ||
This package is optimized for small byte inputs (<10kb). | ||
It is highly recommended to run CPU-intensive tasks in a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers). | ||
Also, it is highly recommended to run CPU-intensive tasks in a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers). | ||
```js | ||
@@ -34,8 +34,15 @@ import sha256 from '@cryptography/sha256' | ||
const hash = sha256('Hello World!') | ||
const bytes = sha256('Hello World!', 'array') | ||
``` | ||
For hashing large files or other data chuncks use `stream()` to create a hashing stream. | ||
```js | ||
sha256.stream().update('Hello World!').digest(); | ||
``` | ||
## Benchmarks | ||
Faster than [forge](https://github.com/digitalbazaar/forge) and [WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API). Benchmark is coming soon. | ||
Faster than [forge](https://github.com/digitalbazaar/forge), [sjcl](https://github.com/bitwiseshiftleft/sjcl) and [WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) in **sequence** mode. | ||
* http://jsben.ch/vBZqA | ||
* https://jsbench.me/i1k3b0xrvy/4 | ||
## Contributing | ||
Contributions are welcome! Contribution guidelines will be published later. | ||
Contributions are welcome! Contribution guidelines will be published soon. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
45
21476
21
6
24
1