use base64 string for custom encrypt/decrypt
This commit is contained in:
@@ -167,10 +167,13 @@ export default class packet {
|
|||||||
|
|
||||||
const customEncryption = getCustomEncryption();
|
const customEncryption = getCustomEncryption();
|
||||||
if (customEncryption) {
|
if (customEncryption) {
|
||||||
this.buffer = await customEncryption.decrypt(
|
this.buffer = Buffer.from(
|
||||||
key,
|
await customEncryption.decrypt(
|
||||||
nonce,
|
key.toString('base64'),
|
||||||
this.buffer.slice(12)
|
nonce.toString('base64'),
|
||||||
|
this.buffer.slice(12).toString('base64')
|
||||||
|
),
|
||||||
|
'base64'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.buffer = new JSChaCha20(key, nonce, 0).decrypt(
|
this.buffer = new JSChaCha20(key, nonce, 0).decrypt(
|
||||||
@@ -290,7 +293,14 @@ export default class packet {
|
|||||||
|
|
||||||
const customEncryption = getCustomEncryption();
|
const customEncryption = getCustomEncryption();
|
||||||
if (customEncryption) {
|
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 {
|
} else {
|
||||||
this.buffer = new JSChaCha20(key, nonce, 0).encrypt(this.buffer);
|
this.buffer = new JSChaCha20(key, nonce, 0).encrypt(this.buffer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user