From 362096dd20a7c607824138e2de5ac60fbaa4458e Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 7 Jun 2021 13:41:26 -0500 Subject: [PATCH] use base64 string for custom encrypt/decrypt --- src/networking/packet.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/networking/packet.js b/src/networking/packet.js index 2a34bd2..5c2a2cb 100644 --- a/src/networking/packet.js +++ b/src/networking/packet.js @@ -167,10 +167,13 @@ export default class packet { const customEncryption = getCustomEncryption(); if (customEncryption) { - this.buffer = await customEncryption.decrypt( - key, - nonce, - this.buffer.slice(12) + this.buffer = Buffer.from( + await customEncryption.decrypt( + key.toString('base64'), + nonce.toString('base64'), + this.buffer.slice(12).toString('base64') + ), + 'base64' ); } else { this.buffer = new JSChaCha20(key, nonce, 0).decrypt( @@ -290,7 +293,14 @@ export default class packet { const customEncryption = getCustomEncryption(); if (customEncryption) { - this.buffer = await customEncryption.encrypt(key, nonce, this.buffer); + this.buffer = Buffer.from( + await customEncryption.encrypt( + key.toString('base64'), + nonce.toString('base64'), + this.buffer.toString('base64') + ), + 'base64' + ); } else { this.buffer = new JSChaCha20(key, nonce, 0).encrypt(this.buffer); }