A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: convert string plaintext to Uint8Array for accurate length derivation
thecodrrfe887f58e1c9
diff --git a/apps/web/packages/nncrypto/src/encryption.ts b/apps/web/packages/nncrypto/src/encryption.tsindex f3137b5ed..38c77674e 100644--- a/apps/web/packages/nncrypto/src/encryption.ts+++ b/apps/web/packages/nncrypto/src/encryption.ts@@ -10,6 +10,7 @@ import {from_base64,base64_variants,StateAddress,+ from_string,} from "libsodium-wrappers";import KeyUtils from "./keyutils";import {@@ -28,11 +29,17 @@ export default class Encryption {): Cipher {const encryptionKey = KeyUtils.transform(key);- let data: Uint8Array | string = plaintext.data;+ let data: Uint8Array | null = null;if (typeof plaintext.data === "string" && plaintext.format === "base64") {data = from_base64(plaintext.data, base64_variants.ORIGINAL);+ } else if (typeof plaintext.data === "string") {+ data = from_string(plaintext.data);+ } else if (plaintext.data instanceof Uint8Array) {+ data = plaintext.data;}+ if (!data) throw new Error("Data cannot be null.");+const nonce = randombytes_buf(crypto_aead_xchacha20poly1305_ietf_NPUBBYTES);const cipher: string | Uint8Array =