These functions are baseline as of September 2025.
const encodedPassword = encoder.encode(password);
const additionalData = encoder.encode('https://github.com/ardislu/static-encrypt');
- const contentBuffer = Uint8Array.from(atob(content), c => c.charCodeAt(0));
+ const contentBuffer = Uint8Array.fromBase64(content);
const salt = new Uint8Array(32);
const iv = new Uint8Array(12);
const ciphertext = new Uint8Array(contentBuffer.byteLength - salt.byteLength - iv.byteLength);
contentBuffer.set(salt);
contentBuffer.set(iv, salt.byteLength);
contentBuffer.set(ciphertext, salt.byteLength + iv.byteLength);
- const content = btoa(String.fromCharCode(...contentBuffer));
+ const content = contentBuffer.toBase64();
return content;
}
\ No newline at end of file