libauth icon indicating copy to clipboard operation
libauth copied to clipboard

Simple node 12 example

Open mattcollier opened this issue 6 years ago • 0 comments

The following works with node 12.14.0.

// index.mjs
import bitcoints from 'bitcoin-ts';
import crypto from 'crypto';

/*
import { instantiateSha256 } from 'bitcoin-ts';
produces error: 
import { instantiateSha256 } from 'bitcoin-ts';
         ^^^^^^^^^^^^^^^^^
SyntaxError: The requested module 'bitcoin-ts' does not provide an export named 'instantiateSha256'
*/

(async () => {
  const b = Buffer.from('hello');
  const bitcoinSha256 = await bitcoints.instantiateSha256();
  console.log('bitcoin-ts', Buffer.from(bitcoinSha256.hash(b)).toString('hex'));
  const nodeSha256 = crypto.createHash('sha256').update(b).digest('hex');
  console.log('nodecrypto', nodeSha256);
})();
node --experimental-modules index.mjs

mattcollier avatar Dec 31 '19 23:12 mattcollier