use base64 string for custom encrypt/decrypt
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user