Javax.Crypto.Cipher.Init Method
Initializes this cipher instance with the specified key, algorithm parameters and a source of randomness.

Syntax

[Android.Runtime.Register("init", "(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)V", "")]
public void Init ([Android.Runtime.GeneratedEnum] CipherMode opmode, Java.Security.IKey key, Java.Security.Spec.IAlgorithmParameterSpec params, Java.Security.SecureRandom random)

Parameters

opmode
the operation this cipher instance should be initialized for (one of: ENCRYPT_MODE, DECRYPT_MODE, WRAP_MODE or UNWRAP_MODE).
key
the input key for the operation.
params
the algorithm parameters.
random
the source of randomness to use.

Exceptions

TypeReason
Java.Security.InvalidKeyExceptionif the specified key can not be used to initialize this cipher instance.
Java.Security.InvalidAlgorithmParameterExceptionit the specified parameters are inappropriate for this cipher.
Java.Security.InvalidParameterExceptionif the specified opmode is invalid.

Remarks

Initializes this cipher instance with the specified key, algorithm parameters and a source of randomness.

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 and params is null, the underlying implementation of this cipher is supposed to generate the required parameters (using its provider or random values). Random values are generated using random;

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 it init method.

[Android Documentation]

Requirements

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