mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-03 00:46:19 +01:00
crypto: concat buffers in encryptStream and decryptStream
This commit is contained in:
parent
6ed03b0035
commit
48ac75b135
1 changed files with 2 additions and 2 deletions
|
@ -13,7 +13,7 @@ export function encryptStream(str, iv, secret) {
|
|||
const key = scryptSync(Buffer.from(secret, "base64"), "salt", keyLength);
|
||||
const cipher = createCipheriv(algorithm, key, Buffer.from(iv, "base64"));
|
||||
|
||||
return Buffer.from(cipher.update(buff, "utf8", "binary") + cipher.final("binary"), "binary");
|
||||
return Buffer.concat([ cipher.update(buff), cipher.final() ])
|
||||
}
|
||||
|
||||
export function decryptStream(buf, iv, secret) {
|
||||
|
@ -22,5 +22,5 @@ export function decryptStream(buf, iv, secret) {
|
|||
const key = scryptSync(Buffer.from(secret, "base64"), "salt", keyLength);
|
||||
const decipher = createDecipheriv(algorithm, key, Buffer.from(iv, "base64"));
|
||||
|
||||
return decipher.update(buff, "binary", "utf8") + decipher.final("utf8");
|
||||
return Buffer.concat([ decipher.update(buff), decipher.final() ])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue