Crypto Lib
    Preparing search index...

    Function encryptWithVersion

    • Encrypt plaintext using the current key, returning the ciphertext and the key version used.

      Parameters

      • ring: KeyRing

        The key ring (current key is used).

      • plaintext: string

        The data to encrypt.

      Returns { ciphertext: string; version: string }

      Ciphertext (base64) and version identifier.

      • ciphertext: string

        Base64-encoded ciphertext (nonce || ciphertext || tag).

      • version: string

        Key version used for encryption.

      const { ciphertext, version } = encryptWithVersion(ring, "secret");