@cryptography/sha512
Advanced tools
Comparing version 0.1.0 to 0.1.1
/** | ||
* Refs: | ||
* - https://github.com/digitalbazaar/forge/blob/master/lib/sha512.js | ||
* - https://github.com/bitwiseshiftleft/sjcl/blob/master/core/sha512.js | ||
* | ||
* Rewritten and optimized | ||
*/ | ||
/** | ||
* Calculates sha512 hash from string | ||
*/ | ||
export default function sha512(message: string): string; | ||
declare function sha512(message: string): string; | ||
declare namespace sha512 { | ||
var stream: () => StreamInterface; | ||
var blockLength: number; | ||
} | ||
declare function sha512(message: string, out: 'array'): Uint32Array; | ||
declare namespace sha512 { | ||
var stream: () => StreamInterface; | ||
var blockLength: number; | ||
} | ||
interface StreamInterface { | ||
data: string; | ||
length: number; | ||
state: Uint32Array; | ||
update(data: string): StreamInterface; | ||
digest(): string; | ||
digest(format: 'array'): Uint32Array; | ||
} | ||
export default sha512; |
{ | ||
"name": "@cryptography/sha512", | ||
"description": "https://github.com/js-cryptography/sha512", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"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.2", | ||
"ts-jest": "^24.2.0", | ||
@@ -42,3 +43,3 @@ "ts-loader": "^6.2.1", | ||
}, | ||
"main": "dist/index.js", | ||
"main": "dist/cjs/sha512.min.js", | ||
"types": "dist/index.d.ts", | ||
@@ -45,0 +46,0 @@ "repository": { |
# @cryptography/sha512 | ||
[![Bundlephobia](https://img.shields.io/bundlephobia/minzip/@cryptography/sha512)](https://bundlephobia.com/result?p=@cryptography/sha512@0.1.0) | ||
[![Coverage](https://img.shields.io/codecov/c/github/js-cryptography/sha512?token=617017dc35344eb6b4637420457746c8)](https://codecov.io/gh/js-cryptography/sha512) | ||
[![Travis CI](https://img.shields.io/travis/js-cryptography/sha512)](https://travis-ci.com/js-cryptography/sha512) | ||
@@ -12,6 +15,15 @@ High-performance synchronous SHA-512 implementation for JavaScript. Optimized for browsers. | ||
## Setup | ||
[Package](https://www.npmjs.com/package/@cryptography/sha512) is available through `npm` and `yarn` | ||
``` | ||
npm install @cryptography/sha512 | ||
``` | ||
``` | ||
yarn add @cryptography/sha512 | ||
``` | ||
## 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 | ||
@@ -21,5 +33,10 @@ import sha512 from '@cryptography/sha512' | ||
const hash = sha512('Hello World!') | ||
const bytes = sha512('Hello World!', 'array') | ||
``` | ||
For hashing large files or other data chuncks use `stream()` to create a hashing stream. | ||
```js | ||
sha512.stream().update('Hello World!').digest(); | ||
``` | ||
## Contributing | ||
Contributions are welcome! Contribution guidelines will be published later. |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
40
33064
21
29
2