# Overview of E2EE

**End-to-End Encryption (E2EE)** adds an extra layer of security to your communications by encrypting the data transmitted between the server and client. The process begins with a key exchange where the client and server share keys for encrypting and decrypting messages. This exchange acts like a handshake and ensures that all subsequent communications are encrypted. Only the intended server and client are able to decrypt the messages.

# Steps to Enable E2EE in the SDK

## 1. Set Up a Custom Server for E2EE

Initialize the Welcome SDK with a custom server for E2EE as follows:

### Kotlin
```kotlin
IncodeWelcome.Builder(this, WELCOME_API_URL, WELCOME_API_KEY, E2EE_URL)
    .build()
```

### Java
```java
new IncodeWelcome.Builder(this, WELCOME_API_URL, WELCOME_API_KEY, E2EE_URL)
    .build();
```

## 2. Enable E2EE via `SessionConfig`

### Kotlin
```kotlin
val sessionConfig: SessionConfig = SessionConfig.Builder()
    .setE2eEncryptionEnabled(true)
    .build()
```

### Java
```java
SessionConfig sessionConfig = new SessionConfig.Builder()
    .setE2eEncryptionEnabled(true)
    .build();
```

> ### Note for users that cannot obscure production code
>
> As the `setE2eEncryptionEnabled()` setting is a highly probable target for fraudsters, it's recommended that you take extra effort to protect this code against reverse engineering.

## 3. Pass the `SessionConfig` Object

You can pass the `SessionConfig` object to `IncodeWelcome` when starting a `Flow`. There are two methods to do this based on the API you are using:

### 3.1 For Simple `Flows`

### Kotlin
```kotlin
IncodeWelcome.getInstance().startOnboarding(
    activityContext,
    sessionConfig,
    flowConfig,
    onboardingListener)
```

### Java
```java
IncodeWelcome.getInstance().startOnboarding(
    activityContext,
    sessionConfig,
    flowConfig,
    onboardingListener);
```

### 3.2 For Advanced Usage

### Kotlin
```kotlin
... 
IncodeWelcome.getInstance().startOnboardingSection(
    activityContext,
    sessionConfig,
    flowConfig,
    onboardingListener
)
```

### Java
```java
... 
IncodeWelcome.getInstance().startOnboardingSection(
    activityContext,
    sessionConfig,
    flowConfig,
    onboardingListener);
```
