https://github.com/clems71/co-sha1
https://github.com/clems71/co-sha1
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/clems71/co-sha1
- Owner: clems71
- Created: 2016-10-17T12:24:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-09T13:07:36.000Z (about 9 years ago)
- Last Synced: 2025-06-10T19:01:12.633Z (about 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# co-sha1
## Install
$ npm install co-sha1
## Doc
- `sha1(string)` : synchronous version, returns an hex string containing the SHA1 sum
- `sha1(Buffer)` : synchronous version, returns an hex string containing the SHA1 sum
- `sha1(ReadableStream)` : asynchronous version, returns a Promise\, resolved to SHA1 sum once finished
## Usage
```js
const fs = require('fs')
const sha1 = require('co-sha1')
async function test () {
// Synchronous with strings and Buffers
console.log(sha1('hello world!'))
// → 430ce34d020724ed75a196dfc2ad67c77772d169
console.log(sha1(new Buffer('hello world!')))
// → 430ce34d020724ed75a196dfc2ad67c77772d169
// Asynchronous with Streams
console.log(await sha1(fs.createReadStream('hello.txt')))
// → 430ce34d020724ed75a196dfc2ad67c77772d169
}
test().catch(console.error);
```