Skip to main content
Generates a random 32-byte (256-bit) key for creating an encrypted index with an SDK-supplied key.
The static and instance forms are identical; use the static form when you don’t have a client yet.

Returns

Uint8Array: 32 bytes from the runtime’s Web Crypto crypto.getRandomValues(). This works the same on Node.js, browsers, and Edge runtimes, and throws if the runtime has no Web Crypto implementation. Unlike the Python SDK, there is no option to save the key to a file.
An index created with an SDK-supplied key can only be opened with that exact key. If the key is lost, the index’s data can’t be decrypted. Store it in a secrets manager, or use a KMS-backed index. See Managing Encryption Keys.

Example Usage