node bindings for cryptonight hashing
node-cryptonight requires Boost and Sodium
sudo apt-get install libboost-all-dev libsodium-dev
brew install boost
brew install libsodium
npm install --save node-cryptonight
Code is linted with standard and tested with Jest. Run npm test to lint and run tests.
const cryptonight = require('node-cryptonight').hash
const hash = cryptonight(Buffer.from('This is a test'))
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>const cryptonight = require('node-cryptonight').hash
const hash = cryptonight(Buffer.from('This is a test'), 1)
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>const cryptonight = require('node-cryptonight').hash
const hash = cryptonight(Buffer.from('This is a test'), 1, 123)
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>const cryptonight = require('node-cryptonight').asyncHash
cryptonight(Buffer.from('This is a test'), hash => {
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
})const cryptonight = require('node-cryptonight').asyncHash
cryptonight(Buffer.from('This is a test'), 1, hash => {
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
})const cryptonight = require('node-cryptonight').asyncHash
cryptonight(Buffer.from('This is a test'), 4, 123, hash => {
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
})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) // <Buffer a0 84 f0 1d 14 37 ..>Released under the 3-Clause BSD License. Contains code from the Monero project. See LICENSE for more information.