Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ console.log(sha256stream.read().toString('hex'))
Note, this doesn't actually implement a stream, but wrapping this in a stream is trivial.
It does update incrementally, so you can hash things larger than RAM, as it uses a constant amount of memory (except when using base64 or utf8 encoding, see code comments).

## TypeScript

Library can be used with types, use [`npm i @types/sha.js`](https://www.npmjs.com/package/@types/sha.js) and add `sha.js` under `types` in your `tsconfig.json`. Expected type-checking can be illustrated as follows:
```ts
return sha(algorithm as 'sha' | 'sha1' | 'sha224' | 'sha256' | 'sha384' | 'sha512')
.update(data as string | NodeJS.ArrayBufferView)
.digest(encoding as 'latin1' | 'hex' | 'base64')
```

## Acknowledgements
This work is derived from Paul Johnston's [A JavaScript implementation of the Secure Hash Algorithm](http://pajhome.org.uk/crypt/md5/sha1.html).
Expand Down