js-nacl
js-nacl copied to clipboard
Newbie question on using the factory
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