Fake Mirrors
    Preparing search index...

    Function encrypt

    • Encrypts a plaintext string using AES-256-GCM.

      The process is as follows:

      1. The plaintext is compressed using deflate for efficiency.
      2. A random salt and IV are generated.
      3. A key is derived from the secret and salt using scrypt.
      4. The compressed data is encrypted with the derived key and IV.
      5. The salt, IV, authentication tag, and ciphertext are concatenated.
      6. The final binary data is encoded into a URL-safe Base64 string.

      Parameters

      • text: string

        The plaintext to encrypt. Must be a non-empty string.

      • secret: string

        The secret passphrase for encryption. Must be a non-empty string.

      Returns string

      The URL-safe Base64 encoded ciphertext, which includes the salt, IV, and auth tag.

      Error If text or secret is empty.

      Error If the encryption or compression process fails.