Fake Mirrors
    Preparing search index...

    Function encrypt

    • Encrypt a string with a secret using AES-256-GCM.

      The string is first compressed using deflate, then encrypted with a random IV and salt. The result is encoded as URL-safe Base64.

      Parameters

      • text: string

        The plaintext to encrypt

      • secret: string

        The secret key for encryption

      Returns string

      URL-safe Base64 encoded ciphertext (includes salt, IV, and auth tag)

      const encrypted = encrypt('Secret message', 'mySecret123')
      console.log(encrypted)