# KeyStore.SecretKeyEntry

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

# SecretKeyEntry

```
class SecretKeyEntry : KeyStore.Entry
```

|---|--------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                 ||
| ↳ | [java.security.KeyStore.SecretKeyEntry](https://developer.android.com/reference/kotlin/java/security/KeyStore.SecretKeyEntry#) |

A`KeyStore`entry that holds a`SecretKey`.

## Summary

|                                                                                                                                                                                                                                                                                                   Public constructors                                                                                                                                                                                                                                                                                                   ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [SecretKeyEntry](https://developer.android.com/reference/kotlin/java/security/KeyStore.SecretKeyEntry#SecretKeyEntry(javax.crypto.SecretKey))`(`secretKey:` `[SecretKey](https://developer.android.com/reference/kotlin/javax/crypto/SecretKey.html#)!`)` Constructs a`SecretKeyEntry`with a`SecretKey`.                                                                                                                                                                                                                                                                                                             |
| [SecretKeyEntry](https://developer.android.com/reference/kotlin/java/security/KeyStore.SecretKeyEntry#SecretKeyEntry(javax.crypto.SecretKey,%20kotlin.collections.MutableSet))`(`secretKey:` `[SecretKey](https://developer.android.com/reference/kotlin/javax/crypto/SecretKey.html#)!`, `attributes:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[KeyStore.Entry.Attribute](https://developer.android.com/reference/kotlin/java/security/KeyStore.Entry.Attribute)!>!`)` Constructs a`SecretKeyEntry`with a`SecretKey`and associated entry attributes. |

|                                                                                                                                                                                               Public methods                                                                                                                                                                                               ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[KeyStore.Entry.Attribute](https://developer.android.com/reference/kotlin/java/security/KeyStore.Entry.Attribute)!\>! | [getAttributes](https://developer.android.com/reference/kotlin/java/security/KeyStore.SecretKeyEntry#getAttributes())`()` Retrieves the attributes associated with an entry. |
| [SecretKey](https://developer.android.com/reference/kotlin/javax/crypto/SecretKey.html#)!                                                                                                                                    | [getSecretKey](https://developer.android.com/reference/kotlin/java/security/KeyStore.SecretKeyEntry#getSecretKey())`()` Gets the`SecretKey`from this entry.                  |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                                                                                                                                             | [toString](https://developer.android.com/reference/kotlin/java/security/KeyStore.SecretKeyEntry#toString())`()` Returns a string representation of this SecretKeyEntry.      |

## Public constructors

### SecretKeyEntry

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

```
SecretKeyEntry(secretKey: SecretKey!)
```

Constructs a`SecretKeyEntry`with a`SecretKey`.

|                                                      Parameters                                                       ||
|-------------|----------------------------------------------------------------------------------------------------------|
| `secretKey` | [SecretKey](https://developer.android.com/reference/kotlin/javax/crypto/SecretKey.html#)!:the`SecretKey` |

|                       Exceptions                        ||
|----------------------------------|-----------------------|
| `java.lang.NullPointerException` | if`secretKey`is`null` |

### SecretKeyEntry

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

```
SecretKeyEntry(
    secretKey: SecretKey!, 
    attributes: MutableSet<KeyStore.Entry.Attribute!>!)
```

Constructs a`SecretKeyEntry`with a`SecretKey`and associated entry attributes.

The specified`attributes`is cloned before it is stored in the new`SecretKeyEntry`object.

|                                                                                                                        Parameters                                                                                                                         ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `secretKey`  | [SecretKey](https://developer.android.com/reference/kotlin/javax/crypto/SecretKey.html#)!:the`SecretKey`                                                                                                                                    |
| `attributes` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[KeyStore.Entry.Attribute](https://developer.android.com/reference/kotlin/java/security/KeyStore.Entry.Attribute)!\>!:the attributes |

|                              Exceptions                               ||
|----------------------------------|-------------------------------------|
| `java.lang.NullPointerException` | if`secretKey`or`attributes`is`null` |

## Public methods

### getAttributes

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

```
fun getAttributes(): MutableSet<KeyStore.Entry.Attribute!>!
```

Retrieves the attributes associated with an entry.

|                                                                                                                                    Return                                                                                                                                     ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[KeyStore.Entry.Attribute](https://developer.android.com/reference/kotlin/java/security/KeyStore.Entry.Attribute)!>! | an unmodifiable`Set`of attributes, possibly empty |

### getSecretKey

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

```
fun getSecretKey(): SecretKey!
```

Gets the`SecretKey`from this entry.

|                                                          Return                                                          ||
|-------------------------------------------------------------------------------------------|-------------------------------|
| [SecretKey](https://developer.android.com/reference/kotlin/javax/crypto/SecretKey.html#)! | the`SecretKey`from this entry |

### toString

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

```
fun toString(): String
```

Returns a string representation of this SecretKeyEntry.

|                                                              Return                                                               ||
|----------------------------------------------------------------------------------|-------------------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of this SecretKeyEntry. |