# MasterKeyKt

Added in 1.1.0

*** ** * ** ***


```
public final class MasterKeyKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/MasterKey` | `[MasterKey](https://developer.android.com/reference/androidx/security/crypto/MasterKeyKt#MasterKey(android.content.Context,kotlin.String,androidx.security.crypto.MasterKey.KeyScheme,kotlin.Boolean,kotlin.Int,kotlin.Boolean))( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html keyAlias, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/MasterKey.KeyScheme keyScheme, boolean authenticationRequired, int userAuthenticationValidityDurationSeconds, boolean requestStrongBoxBacked )` **This method is deprecated.** Use Android Keystore directly instead |

## Public methods

### MasterKey

Artifact: [androidx.security:security-crypto-ktx](https://developer.android.com/jetpack/androidx/releases/security) [View Source](https://cs.android.com/search?q=file:androidx/security/crypto/MasterKey.kt+function:MasterKey) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/security#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/security#1.1.0)

```
public static final @NonNull MasterKey [MasterKey](https://developer.android.com/reference/androidx/security/crypto/MasterKeyKt#MasterKey(android.content.Context,kotlin.String,androidx.security.crypto.MasterKey.KeyScheme,kotlin.Boolean,kotlin.Int,kotlin.Boolean))(
    @NonNull Context context,
    @NonNull String keyAlias,
    @NonNull MasterKey.KeyScheme keyScheme,
    boolean authenticationRequired,
    int userAuthenticationValidityDurationSeconds,
    boolean requestStrongBoxBacked
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Use Android Keystore directly instead

Creates a `https://developer.android.com/reference/androidx/security/crypto/package-summary#MasterKey(android.content.Context,kotlin.String,androidx.security.crypto.MasterKey.KeyScheme,kotlin.Boolean,kotlin.Int,kotlin.Boolean)` with the provided parameters.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | The context to work with. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html keyAlias` | The alias to use for the `MasterKey`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/security/crypto/MasterKey.KeyScheme keyScheme` | The `https://developer.android.com/reference/androidx/security/crypto/MasterKey.KeyScheme` to have the `MasterKey` use. |
| `boolean authenticationRequired` | `true` if the user must authenticate for the `MasterKey` to be used. |
| `int userAuthenticationValidityDurationSeconds` | Duration in seconds that the `MasterKey` is valid for after the user has authenticated. Must be a value \> 0. |
| `boolean requestStrongBoxBacked` | `true` if the key should be stored in Strong Box, if possible. |