Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/excitableaardvark/node-cryptonight
node bindings for cryptonight hashing
https://github.com/excitableaardvark/node-cryptonight
cryptonight hash monero native
Last synced: 3 months ago
JSON representation
node bindings for cryptonight hashing
- Host: GitHub
- URL: https://github.com/excitableaardvark/node-cryptonight
- Owner: ExcitableAardvark
- License: bsd-3-clause
- Created: 2017-12-19T18:56:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T15:14:51.000Z (almost 2 years ago)
- Last Synced: 2024-10-10T01:05:06.791Z (3 months ago)
- Topics: cryptonight, hash, monero, native
- Language: JavaScript
- Size: 1.27 MB
- Stars: 18
- Watchers: 2
- Forks: 12
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-cryptonight
> node bindings for cryptonight hashing### Requirements
node-cryptonight requires [Boost](http://www.boost.org) and [Sodium](http://libsodium.org)
##### Ubuntu
sudo apt-get install libboost-all-dev libsodium-dev
##### Mac
brew install boost
brew install libsodium### Installation
npm install --save node-cryptonight
### TestingCode is linted with [standard](https://github.com/standard/standard) and tested with [Jest](https://github.com/facebook/jest). Run `npm test` to lint and run tests.
### Usage Examples
##### Synchronous Hashing
```js
const cryptonight = require('node-cryptonight').hash
const hash = cryptonight(Buffer.from('This is a test'))
console.log(hash) //
```##### Synchronous Hashing with variant 1
```js
const cryptonight = require('node-cryptonight').hash
const hash = cryptonight(Buffer.from('This is a test'), 1)
console.log(hash) //
```##### Synchronous Hashing with variant 4 and height 123
```js
const cryptonight = require('node-cryptonight').hash
const hash = cryptonight(Buffer.from('This is a test'), 1, 123)
console.log(hash) //
```##### Asynchronous Hashing
```js
const cryptonight = require('node-cryptonight').asyncHash
cryptonight(Buffer.from('This is a test'), hash => {
console.log(hash) //
})
```
##### Asynchronous Hashing with variant 1```js
const cryptonight = require('node-cryptonight').asyncHash
cryptonight(Buffer.from('This is a test'), 1, hash => {
console.log(hash) //
})
```
##### Asynchronous Hashing with variant 4 and height 123```js
const cryptonight = require('node-cryptonight').asyncHash
cryptonight(Buffer.from('This is a test'), 4, 123, hash => {
console.log(hash) //
})
```##### Promise Wrapper Example
```js
function cryptonight(data) {
return new Promise((resolve, reject) => {
require('node-cryptonight').asyncHash(data, hash => {
resolve(hash)
})
})
}cryptonight(Buffer.from('This is a test'))
.then(console.log) //
```### See Also
* [node-cryptonight-lite](https://github.com/ExcitableAardvark/node-cryptonight-lite)
### License
Released under the 3-Clause BSD License. Contains code from the Monero project. See `LICENSE` for more information.