Android Guides | Samples

Javax.Crypto.Cipher Class

This class provides access to implementations of cryptographic ciphers for encryption and decryption.

See Also: Cipher

Syntax

[Android.Runtime.Register("javax/crypto/Cipher", DoNotGenerateAcw=true)]
public class Cipher : Object

Remarks

This class provides access to implementations of cryptographic ciphers for encryption and decryption. Cipher classes can not be instantiated directly, one has to call the Cipher's getInstance method with the name of a requested transformation, optionally with a provider. A transformation specifies an operation (or a set of operations) as a string in the form:

  • "algorithm/mode/padding"
  • "algorithm"
algorithm is the name of a cryptographic algorithm, mode is the name of a feedback mode and padding is the name of a padding scheme. If mode and/or padding values are omitted, provider specific default values will be used.

A valid transformation would be:

    When a block cipher is requested in stream cipher mode, the number of bits to be processed at a time can be optionally specified by appending it to the mode name. e.g. "AES/CFB8/NoPadding". If no number is specified, a provider specific default value is used.

    [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

    The members of Javax.Crypto.Cipher are listed below.

    See Also: Object

    Protected Constructors

    A constructor used when creating managed representations of JNI objects; called by the runtime.
    Creates a new Cipher instance.

    Public Fields

    const
    DecryptModeCipherMode (2). Constant for decryption operation mode.
    const
    EncryptModeCipherMode (1). Constant for encryption operation mode.
    const
    PrivateKeyKeyType (2). Constant indicating that the key to be unwrapped is a private key.
    const
    PublicKeyKeyType (1). Constant indicating that the key to be unwrapped is a public key.
    const
    SecretKeyKeyType (3). Constant indicating that the key to be unwrapped is a secret key.
    const
    UnwrapModeCipherMode (4). Constant for key unwrapping operation mode.
    const
    WrapModeCipherMode (3). Constant for key wrapping operation mode.

    Public Properties

    [read-only]
    AlgorithmString. Returns the name of the algorithm of this cipher instance.
    [read-only]
    BlockSizeInt32. Returns this ciphers block size (in bytes).
    [read-only]
    ExemptionMechanismExemptionMechanism. Returns the exemption mechanism associated with this cipher.
    [read-only]
    ParametersAlgorithmParameters. Returns the parameters that where used to create this cipher instance.
    [read-only]
    ProviderProvider. Returns the provider of this cipher instance.

    Protected Properties

    [read-only]
    override
    ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
    [read-only]
    override
    ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

    Public Methods

    DoFinal() : Byte[]
    Finishes a multi-part transformation (encryption or decryption).
    DoFinal(Byte[]) : Byte[]
    Finishes a multi-part transformation (encryption or decryption).
    DoFinal(ByteBuffer, ByteBuffer) : Int32
    Finishes a multi-part transformation (encryption or decryption).
    DoFinal(Byte[], Int32) : Int32
    Finishes a multi-part transformation (encryption or decryption).
    DoFinal(Byte[], Int32, Int32) : Byte[]
    Finishes a multi-part transformation (encryption or decryption).
    DoFinal(Byte[], Int32, Int32, Byte[]) : Int32
    Finishes a multi-part transformation (encryption or decryption).
    DoFinal(Byte[], Int32, Int32, Byte[], Int32) : Int32
    Finishes a multi-part transformation (encryption or decryption).
    static
    GetInstance(String) : Cipher
    Creates a new Cipher for the specified transformation.
    static
    GetInstance(String, Provider) : Cipher
    Creates a new cipher for the specified transformation.
    static
    GetInstance(String, String) : Cipher
    Creates a new cipher for the specified transformation provided by the specified provider.
    GetIV() : Byte[]
    Returns the initialization vector for this cipher instance.
    static
    GetMaxAllowedKeyLength(String) : Int32
    Returns the maximum key length for the specified transformation.
    static
    GetMaxAllowedParameterSpec(String) : IAlgorithmParameterSpec
    Returns the maximum cipher parameter value for the specified transformation.
    GetOutputSize(Int32) : Int32
    Returns the length in bytes an output buffer needs to be when this cipher is updated with inputLen bytes.
    Init(CipherMode, Certificate)
    Initializes this cipher instance with the public key from the specified certificate.
    Init(CipherMode, IKey)
    Initializes this cipher instance with the specified key.
    Init(CipherMode, Certificate, SecureRandom)
    Initializes this cipher instance with the public key from the specified certificate and a source of randomness.
    Init(CipherMode, IKey, AlgorithmParameters)
    Initializes this cipher instance with the specified key and algorithm parameters.
    Init(CipherMode, IKey, SecureRandom)
    Initializes this cipher instance with the specified key and a source of randomness.
    Init(CipherMode, IKey, IAlgorithmParameterSpec)
    Initializes this cipher instance with the specified key and algorithm parameters.
    Init(CipherMode, IKey, AlgorithmParameters, SecureRandom)
    Initializes this cipher instance with the specified key, algorithm parameters and a source of randomness.
    Init(CipherMode, IKey, IAlgorithmParameterSpec, SecureRandom)
    Initializes this cipher instance with the specified key, algorithm parameters and a source of randomness.
    Unwrap(Byte[], String, KeyType) : IKey
    Unwraps a key using this cipher instance.
    Update(Byte[]) : Byte[]
    Continues a multi-part transformation (encryption or decryption).
    Update(ByteBuffer, ByteBuffer) : Int32
    Continues a multi-part transformation (encryption or decryption).
    Update(Byte[], Int32, Int32) : Byte[]
    Continues a multi-part transformation (encryption or decryption).
    Update(Byte[], Int32, Int32, Byte[]) : Int32
    Continues a multi-part transformation (encryption or decryption).
    Update(Byte[], Int32, Int32, Byte[], Int32) : Int32
    Continues a multi-part transformation (encryption or decryption).
    UpdateAAD(ByteBuffer)
    Continues a multi-part transformation (encryption or decryption) with Authenticated Additional Data (AAD).
    UpdateAAD(Byte[])
    Continues a multi-part transformation (encryption or decryption) with Authenticated Additional Data (AAD).
    UpdateAAD(Byte[], Int32, Int32)
    Continues a multi-part transformation (encryption or decryption) with Authenticated Additional Data (AAD).
    Wrap(IKey) : Byte[]
    Wraps a key using this cipher instance.