Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/crypto/hpke/Sender#nestedclasses) \| [Methods](https://developer.android.com/reference/android/crypto/hpke/Sender#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/crypto/hpke/Sender#inhmethods)

# Sender

*** ** * ** ***


`
public


class
Sender
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.crypto.hpke.Sender |

<br />

*** ** * ** ***

A class for sending HPKE messages.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/crypto/hpke/Sender.Builder` A builder for HPKE Sender objects. |

| ### Public methods ||
|---|---|
| ` byte[]` | ` https://developer.android.com/reference/android/crypto/hpke/Sender#export(int,%20byte[])(int length, byte[] context) ` Exports secret key material from this Sender as described in RFC 9180. |
| ` byte[]` | ` https://developer.android.com/reference/android/crypto/hpke/Sender#getEncapsulated()() ` Returns the encapsulated ephemeral key created for this Sender. |
| ` https://developer.android.com/reference/java/security/Provider` | ` https://developer.android.com/reference/android/crypto/hpke/Sender#getProvider()() ` Returns the `https://developer.android.com/reference/java/security/Provider` being used by this Sender. |
| ` https://developer.android.com/reference/android/crypto/hpke/HpkeSpi` | ` https://developer.android.com/reference/android/crypto/hpke/Sender#getSpi()() ` Returns the `https://developer.android.com/reference/android/crypto/hpke/HpkeSpi` being used by this Sender. |
| ` byte[]` | ` https://developer.android.com/reference/android/crypto/hpke/Sender#seal(byte[],%20byte[])(byte[] plaintext, byte[] aad) ` Seals a message, using the internal key schedule maintained by this Sender. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public methods

### export

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] export (int length, 
                byte[] context)
```

Exports secret key material from this Sender as described in RFC 9180.

<br />

| Parameters ||
|---|---|
| `length` | `int`: expected output length <br /> |
| `context` | `byte`: optional exporter context string, may be null or empty <br /> |

| Returns ||
|---|---|
| `byte[]` | the exported value. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the length is not valid for the Sender's KDF |

### getEncapsulated

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] getEncapsulated ()
```

Returns the encapsulated ephemeral key created for this Sender.

<br />

| Returns ||
|---|---|
| `byte[]` | the encapsulated key. This value cannot be `null`. <br /> |

### getProvider

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Provider getProvider ()
```

Returns the `https://developer.android.com/reference/java/security/Provider` being used by this Sender.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/security/Provider` | the Provider. This value cannot be `null`. <br /> |

### getSpi

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public HpkeSpi getSpi ()
```

Returns the `https://developer.android.com/reference/android/crypto/hpke/HpkeSpi` being used by this Sender.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/crypto/hpke/HpkeSpi` | the SPI. This value cannot be `null`. <br /> |

### seal

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] seal (byte[] plaintext, 
                byte[] aad)
```

Seals a message, using the internal key schedule maintained by this Sender.

<br />

| Parameters ||
|---|---|
| `plaintext` | `byte`: the plaintext. This value cannot be `null`. <br /> |
| `aad` | `byte`: optional additional authenticated data, may be null or empty <br /> |

| Returns ||
|---|---|
| `byte[]` | the ciphertext. This value cannot be `null`. <br /> |

**See also:**

- [Opening and sealing](https://www.rfc-editor.org/rfc/rfc9180.html#name-encryption-and-decryption-2)