Function: encryptContent() ​

Source: 1.1.0 · a1d5eeca2f43

ts
function encryptContent(content, options): Promise<string>;

Defined in: packages/valaxy/node/utils/encrypt.ts:53

Encrypt content and return the ciphertext as base64.

The ciphertext is embedded in the compiled page module, which UnoCSS scans for utilities. A raw binary string (String.fromCharCode per byte) carries quotes, brackets, $, * and backslashes, so random bytes could form tokens like p-["*(.] that UnoCSS turns into unparsable CSS, failing the build at random because salt/iv change on every build. Base64 has none of those characters, and it is smaller once JSON-escaped.

Breaking change: before this, the return value was a binary string (one char per byte). Code that decodes it outside useDecrypt must now atob it first.

Parameters ​

content ​

string

options ​

iv ​

Uint8Array

password ​

string

salt ​

Uint8Array

Returns ​

Promise<string>

See ​

https://github.com/mdn/dom-examples/blob/main/web-crypto/encrypt-decrypt/aes-cbc.js