TypeError in Firefox 40.0.3
chickahoona opened this issue · 2 comments
chickahoona commented
Hi,
Im implementing your lib right now for another project but in my Firefox 40.0.3 I get the following error:
TypeError: invalid arguments
nacl_raw.HEAPU8.set(bs, address + p);
nacl_factory.js (Line 26009)
I tested the the same in Chrome and everything seems to work there. I added below a small test script to help to reproduce the error.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TEST</title>
<!-- NaCl, SCrypt and sha512 are mandatory -->
<script src="libs/js-nacl/lib/nacl_factory.js" type="text/javascript"></script>
<script>
var nacl = nacl_factory.instantiate();
</script>
</head>
<body>
<script>
function test (secret, password) {
var k = nacl.crypto_hash_sha256(password);
var m = nacl.encode_utf8(secret);
var n = nacl.crypto_secretbox_random_nonce();
var c = nacl.crypto_secretbox(m, n, k);
return {
nonce: nacl.to_hex(n),
ciphertext: nacl.to_hex(c)
}
}
console.log(test("mySecret", "myPassword"));
</script>
</body>
</html>
Thanks in advance and thanks for that nice lib.
blavenie commented
I get the same issue, on Firefox 44.0... with nacl version 0.6.0
tonyg commented
You need to encode the password string to bytes, too:
var k = nacl.crypto_hash_sha256(nacl.encode_utf8(password));
See https://github.com/tonyg/js-nacl/#strings-vs-binary-data.