encryptWith

suspend fun encryptWith(registry: JwtProcessorRegistry, keyAlgorithm: EncryptionAlgorithm, contentAlgorithm: EncryptionContentAlgorithm, keyId: String? = null): JwtInstance.Jwe(source)

Looks up the public key from registry and builds a JWE compact serialization.

The registry is searched using keyAlgorithm and keyId as the look-up criteria (see DefaultJwtProcessorRegistry for the full look-up order). If no matching key is found an IllegalStateException is thrown.

Return

the resulting JwtInstance.Jwe compact serialization

Parameters

registry

the key registry to look up the public encryption key from

keyAlgorithm

the key encryption algorithm used to wrap the content encryption key

contentAlgorithm

the content encryption algorithm used to encrypt the payload

keyId

optional key ID used for registry look-up and embedded in the JWE header's kid field. Defaults to null.

See also

Throws

if no encryption key for keyAlgorithm (and keyId) is found in registry