js-nacl icon indicating copy to clipboard operation
js-nacl copied to clipboard

Newbie question on using the factory

Open teamimx opened this issue 5 years ago • 0 comments

I would like to use js-nacl in a Quasar/Vue project but struggle a bit with the factory callback instantiation. What I would like to do is:

createHashHex: function (myString) {
  var naclFactory = require('js-nacl')
  var nacl
  naclFactory.instantiate(function (naclInstance) {
    nacl = naclInstance
  })
  let pwHashArray = nacl.crypto_hash_string(myString)
  let pwHashHex = nacl.to_hex(pwHashArray)
  return pwHashHex
}

But that does not work. How do I correctly instantiate the stuff without using the inline notation in the docs?

Cheers, Michael

teamimx avatar Nov 05 '19 22:11 teamimx