1.3.0 • Published 5 years ago

node-cryptonight-old-hardware v1.3.0

Weekly downloads
5
License
BSD-3-Clause
Repository
github
Last release
5 years ago

node-cryptonight-old-hardware

node bindings for cryptonight hashing on old hardware that does not support AES-NI extensions

Cryptonight hashing functions for node.js.

Recommended for usage on old hardware, prefer using node-cryptonight on modern hardware and production.

Supports cryptonight variant: 0, 1, 2 and 4.

Installation

npm install --save node-cryptonight-old-hardware

Testing

Code is linted with standard and tested with Jest. Run npm test to lint and run tests.

Usage Examples

Synchronous Hashing
const cryptonight = require('node-cryptonight-old-hardware').hash
const hash = cryptonight(Buffer.from('This is a test'))
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
Synchronous Hashing with variant 1
const cryptonight = require('node-cryptonight-old-hardware').hash
const hash = cryptonight(Buffer.from('This is a test'), 1)
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
Synchronous Hashing with variant 4 and height 123
const cryptonight = require('node-cryptonight-old-hardware').hash
const hash = cryptonight(Buffer.from('This is a test'), 4, 123)
console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
Asynchronous Hashing
const cryptonight = require('node-cryptonight-old-hardware').asyncHash
cryptonight(Buffer.from('This is a test'), hash => {
  console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
})
Asynchronous Hashing with variant 1
const cryptonight = require('node-cryptonight-old-hardware').asyncHash
cryptonight(Buffer.from('This is a test'), 1, hash => {
  console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
})
Asynchronous Hashing with variant 4 and height 123
const cryptonight = require('node-cryptonight-old-hardware').asyncHash
cryptonight(Buffer.from('This is a test'), 4, 123, hash => {
  console.log(hash) // <Buffer a0 84 f0 1d 14 37 ..>
})
Promise Wrapper Example
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 ..>

See Also

Following libraries have similar API with AES-NI support:

Hashing algorithm implementations are provided by:

License

Released under the 3-Clause BSD License. Contains code from the Monero project. See LICENSE for more information.