android-components / mozilla.components.lib.dataprotect / Keystore / createEncryptCipher

# createEncryptCipher

`fun createEncryptCipher(): Cipher` (source)

Create a cipher initialized for encrypting data with the managed key.

This "low-level" method is useful when a cryptographic context is needed to integrate with other APIs, such as the `FingerprintManager`.

NOTE: The caller is responsible for associating certain encryption factors, such as the initialization vector and/or additional authentication data (AAD), with the resulting ciphertext or decryption will fail.

### Exceptions

`InvalidKeyException` - If the key does not exist, or is not a SecretKey

`NoSuchAlgorithmException` - If the cipher algorithm is not supported

`NoSuchPaddingException` - If the padding format is not supported

Return
The Cipher, initialized and ready to encrypt data with.