<a id="code-examples-csfle"></a>

# Code Examples for Client-Side Field Level Encryption in Confluent Cloud

The following code examples and demos (for Java, Go, C#/.NET, JavaScript, and Python)
can be used to help you use client-side field level encryption in Confluent Cloud. These
examples are available in the [Client-Side Field Level Encryption (CSFLE) Examples](https://github.com/confluentinc/csfle-examples#readme)
GitHub repository.

## Requirements

* A Confluent Cloud cluster with Advanced Stream Governance enabled. For details,
  see [Dependency on Stream Governance](overview.md#csfle-governance-dependency).
* For clients supporting CSFLE, see [Requirements](client-side.md#csfle-requirements).

## Examples

### Java

These following examples for producers and consumers use the supported Java client for Apache Kafka®. For details, see
[Apache Kafka Java Client](https://docs.confluent.io/clients-kafka-java/current/overview.html).

* [Client-Side Field Level Encryption (CSFLE) with AWS KMS](https://github.com/confluentinc/csfle-examples/tree/master/aws#readme)
* [Client-Side Field Level Encryption (CSFLE) with Azure Key Vault](https://github.com/confluentinc/csfle-examples/tree/master/azure#readme)
* [Client-Side Field Level Encryption (CSFLE) with Google Cloud KMS](https://github.com/confluentinc/csfle-examples/tree/master/gcp#readme)
* [Client-Side Field Level Encryption (CSFLE) with HashiCorp Vault](https://github.com/confluentinc/csfle-examples/tree/master/hashicorp#readme)

### Go

These examples use the supported Golang client for Apache Kafka®. For details, see
[Confluent’s Golang Client for Apache Kafka](https://github.com/confluentinc/confluent-kafka-go).

#### Avro

* [Producer encryption example (using Avro)](https://github.com/confluentinc/confluent-kafka-go/tree/master/examples/avrov2_producer_encryption_example#readme)
* [Consumer decryption example (using Avro)](https://github.com/confluentinc/confluent-kafka-go/tree/master/examples/avrov2_consumer_encryption_example#readme)

#### JSON

* [Producer encryption example (using JSON)](https://github.com/confluentinc/confluent-kafka-go/tree/master/examples/json_producer_encryption_example#readme)
* [Consumer decryption example (using JSON)](https://github.com/confluentinc/confluent-kafka-go/tree/master/examples/json_consumer_encryption_example#readme)

#### Protobuf

* [Producer encryption example (using Protobuf)](https://github.com/confluentinc/confluent-kafka-go/tree/master/examples/protobuf_producer_encryption_example)
* [Consumer decryption example (using Protobuf)](https://github.com/confluentinc/confluent-kafka-go/tree/master/examples/protobuf_consumer_encryption_example)

### C#/.NET

The following examples use Confluent’s .NET client for Apache Kafka®. For details, see
[Confluent’s .NET client for Apache Kafka](https://github.com/confluentinc/confluent-kafka-dotnet).

#### Avro

* [Generic encryption example (using Avro)](https://github.com/confluentinc/confluent-kafka-dotnet/tree/master/examples/AvroGenericEncryption#readme)
* [Specific encryption example (using Avro)](https://github.com/confluentinc/confluent-kafka-dotnet/tree/master/examples/AvroSpecificEncryption#readme)

#### JSON

* [Encryption example (using JSON)](https://github.com/confluentinc/confluent-kafka-dotnet/tree/master/examples/JsonEncryption#readme)

#### Protobuf

* [Encryption example (using Protobuf)](https://github.com/confluentinc/confluent-kafka-dotnet/tree/master/examples/ProtobufEncryption#readme)

### JavaScript

The following examples use the supported Confluent JavaScript Client for Apache Kafka®. For details, see
[Confluent’s JavaScript Client for Apache Kafka](https://github.com/confluentinc/confluent-kafka-javascript).

#### Avro

* [Producer and consumer example (using Avro)](https://github.com/confluentinc/confluent-kafka-javascript/blob/master/schemaregistry-examples/src/csfle-schemaregistry.ts)

### Python

The following examples use the supported Python client for Apache Kafka®. For details, see
[Confluent’s Python Client for Apache Kafka](https://github.com/confluentinc/confluent-kafka-python).

#### Avro

* [Producer encryption example (using Avro)](https://github.com/confluentinc/confluent-kafka-python/blob/master/examples/avro_producer_encryption.py)
* [Consumer decryption example (using Avro)](https://github.com/confluentinc/confluent-kafka-python/blob/master/examples/avro_consumer_encryption.py)

#### JSON

* [Producer encryption example (using JSON)](https://github.com/confluentinc/confluent-kafka-python/blob/master/examples/json_producer_encryption.py)
* [Consumer decryption example (using JSON)](https://github.com/confluentinc/confluent-kafka-python/blob/master/examples/json_consumer_encryption.py)

#### Protobuf

* [Producer encryption example (using Protobuf)](https://github.com/confluentinc/confluent-kafka-python/blob/master/examples/protobuf_producer_encryption.py)
* [Consumer decryption example (using Protobuf)](https://github.com/confluentinc/confluent-kafka-python/blob/master/examples/protobuf_consumer_encryption.py)

## Related content

* [Client-Side Field-Level Encryption (CSFLE) [Confluent Developer Course]](https://developer.confluent.io/courses/csfle/csfle-overview/)
* [Configuration Parameters for Client-Side Field Level Encryption](config-parameters.md#config-parameters-csfle)
* [Protect Sensitive Data Using Client-Side Field Level Encryption on Confluent Cloud](overview.md#csfle-overview)
* [Implement a Custom KMS Driver](custom-kms-driver.md#csfle-custom-kms-driver)
* [Quick Start - Use CSFLE to Protect Sensitive Data](quick-start.md#csfle-quick-start)
* [Kafka Client Quick Start for Confluent Cloud](../../../client-apps/config-client.md#cloud-config-client)
