use base64 string for custom encrypt/decrypt

This commit is contained in:
2021-06-07 13:41:26 -05:00
parent 74aa26e974
commit 362096dd20

View File

@@ -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);
}