Skip to content

Commit 81a7b5d

Browse files
committed
drop explicit buffer allocation code
1 parent b492716 commit 81a7b5d

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

packages/crypto/src/libsodium.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ export class Xchacha20poly1305Ietf {
118118

119119
const cipher = xchacha20poly1305(key, nonce, additionalAuthenticatedData);
120120

121-
let ciphertext: Uint8Array = new Uint8Array(message.length + 16);
122-
ciphertext = cipher.encrypt(message, ciphertext);
123-
124-
return ciphertext;
121+
return cipher.encrypt(message);
125122
}
126123

127124
public static async decrypt(
@@ -133,9 +130,6 @@ export class Xchacha20poly1305Ietf {
133130

134131
const cipher = xchacha20poly1305(key, nonce, additionalAuthenticatedData);
135132

136-
let plaintext: Uint8Array = new Uint8Array(ciphertext.length - 16);
137-
plaintext = cipher.decrypt(ciphertext, plaintext);
138-
139-
return plaintext;
133+
return cipher.decrypt(ciphertext);
140134
}
141135
}

0 commit comments

Comments
 (0)