Android Guides | Samples

Javax.Crypto.Cipher.Init Method

Initializes this cipher instance with the specified key.


[Android.Runtime.Register("init", "(ILjava/security/Key;)V", "")]
public Void Init ([Android.Runtime.GeneratedEnum] CipherMode opmode, IKey key)


the operation this cipher instance should be initialized for (one of: ENCRYPT_MODE, DECRYPT_MODE, WRAP_MODE or UNWRAP_MODE).
the input key for the operation.


InvalidKeyExceptionif the specified key can not be used to initialize this cipher instance.


Initializes this cipher instance with the specified key.

The cipher is initialized for the specified operational mode (one of: encryption, decryption, key wrapping or key unwrapping) depending on opmode.

If this cipher instance needs any algorithm parameters or random values that the specified key can not provide, the underlying implementation of this cipher is supposed to generate the required parameters (using its provider or random values).

When a cipher instance is initialized by a call to any of the init methods, the state of the instance is overridden, meaning that it is equivalent to creating a new instance and calling its init method.

[Android Documentation]


Namespace: Javax.Crypto
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions:
Since: Added in API level 1