xsalsa20-encoding
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -109,3 +109,7 @@ const xsalsa20 = require('xsalsa20') | ||
crypto.randomBytes(NONCE_BYTES).copy(nonce) | ||
if ('function' === typeof opts.nonce) { | ||
opts.nonce().slice(0, NONCE_BYTES).copy(nonce) | ||
} else { | ||
crypto.randomBytes(NONCE_BYTES).copy(nonce) | ||
} | ||
@@ -112,0 +116,0 @@ const xor = xsalsa20(nonce, key) |
{ | ||
"name": "xsalsa20-encoding", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "XSalsa20 codec that implements tha abstract-encoding interface.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
10
test.js
@@ -87,1 +87,11 @@ const blake2b = require('blake2b') | ||
}) | ||
test('custom nonce', (t) => { | ||
const key = crypto.randomBytes(32) | ||
const nonce = crypto.randomBytes(24) | ||
const codec = Codec(key, { nonce: () => nonce }) | ||
const plaintext = Buffer.from('hello') | ||
const encoded = codec.encode(plaintext) | ||
t.ok(0 === Buffer.compare(nonce, encoded.slice(0, 24))) | ||
t.end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12000
247