mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 21:34:06 -06:00
51 lines
1.2 KiB
Markdown
51 lines
1.2 KiB
Markdown
# keccak256
|
|
|
|
> A wrapper for the [`keccak`](https://www.npmjs.com/package/keccak) library to compute 256 bit keccak hash in JavaScript.
|
|
|
|
[](https://raw.githubusercontent.com/miguelmota/keccak256/master/LICENSE.md)
|
|
[](https://travis-ci.org/miguelmota/keccak256)
|
|
|
|
[](https://github.com/feross/standard)
|
|
|
|
## Install
|
|
|
|
```bash
|
|
npm install keccak256
|
|
```
|
|
|
|
### CDN
|
|
|
|
Available on [jsDelivr](https://www.jsdelivr.com/) CDN:
|
|
|
|
```html
|
|
<script src="https://cdn.jsdelivr.net/npm/keccak256@latest/keccak256.js"></script>
|
|
```
|
|
|
|
## Usage
|
|
|
|
- **keccak256**(data) -> {Buffer}
|
|
- {String | Buffer} data - data string or Buffer
|
|
|
|
Returns a Buffer
|
|
|
|
## Getting Started
|
|
|
|
```js
|
|
const keccak256 = require('keccak256')
|
|
|
|
console.log(keccak256('hello').toString('hex')) // "1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
|
|
|
|
console.log(keccak256(Buffer.from('hello')).toString('hex')) // "1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"
|
|
```
|
|
|
|
|
|
## Test
|
|
|
|
```bash
|
|
npm test
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|