Class NullCipher
java.lang.Object
javax.crypto.Cipher
javax.crypto.NullCipher
public class NullCipher extends Cipher
The
NullCipher class is a class that provides an "identity cipher" -- one that does not transform the plain text. As a consequence, the ciphertext is identical to the plaintext. All initialization methods do nothing, while the blocksize is set to 1 byte. Unlike other ciphers, the NullCipher has no state, and will never throw an IllegalStateException when Cipher methods are called.- Since:
- 1.4
Field Summary
Fields declared in class Cipher
DECRYPT_MODE, ENCRYPT_MODE, PRIVATE_KEY, PUBLIC_KEY, SECRET_KEY, UNWRAP_MODE, WRAP_MODE | Modifier and Type | Field | Description |
|---|---|---|
static final int |
DECRYPT_MODE |
Constant used to initialize cipher to decryption mode. |
static final int |
ENCRYPT_MODE |
Constant used to initialize cipher to encryption mode. |
static final int |
PRIVATE_KEY |
Constant used to indicate the to-be-unwrapped key is a "private key". |
static final int |
PUBLIC_KEY |
Constant used to indicate the to-be-unwrapped key is a "public key". |
static final int |
SECRET_KEY |
Constant used to indicate the to-be-unwrapped key is a "secret key". |
static final int |
UNWRAP_MODE |
Constant used to initialize cipher to key-unwrapping mode. |
static final int |
WRAP_MODE |
Constant used to initialize cipher to key-wrapping mode. |
Constructor Summary
| Constructor | Description |
|---|---|
NullCipher() |
Creates a NullCipher object. |
Method Summary
Methods declared in class Cipher
doFinal, doFinal, doFinal, doFinal, doFinal, doFinal, doFinal, getAlgorithm, getBlockSize, getExemptionMechanism, getInstance, getInstance, getInstance, getIV, getMaxAllowedKeyLength, getMaxAllowedParameterSpec, getOutputSize, getParameters, getProvider, init, init, init, init, init, init, init, init, toString, unwrap, update, update, update, update, update, updateAAD, updateAAD, updateAAD, wrap | Modifier and Type | Method | Description |
|---|---|---|
final byte[] |
doFinal() |
Finishes a multiple-part encryption or decryption operation, depending on how this Cipher object was initialized. |
final byte[] |
doFinal |
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
final int |
doFinal |
Finishes a multiple-part encryption or decryption operation, depending on how this Cipher object was initialized. |
final byte[] |
doFinal |
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
final int |
doFinal |
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
final int |
doFinal |
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
final int |
doFinal |
Encrypts or decrypts data in a single-part operation, or finishes a multiple-part operation. |
final String |
getAlgorithm() |
Returns the algorithm name of this Cipher object. |
final int |
getBlockSize() |
Returns the block size (in bytes). |
final ExemptionMechanism |
getExemptionMechanism() |
Returns the exemption mechanism object used with this Cipher object. |
static final Cipher |
getInstance |
Returns a Cipher object that implements the specified transformation. |
static final Cipher |
getInstance |
Returns a Cipher object that implements the specified transformation. |
static final Cipher |
getInstance |
Returns a Cipher object that implements the specified transformation. |
final byte[] |
getIV() |
Returns the initialization vector (IV) in a new buffer. |
static final int |
getMaxAllowedKeyLength |
Returns the maximum key length for the specified transformation according to the installed JCE jurisdiction policy files. |
static final AlgorithmParameterSpec |
getMaxAllowedParameterSpec |
Returns an AlgorithmParameterSpec object which contains the maximum Cipher parameter value according to the jurisdiction policy file. |
final int |
getOutputSize |
Returns the length in bytes that an output buffer would need to be in order to hold the result of the next update or doFinal operation, given the input length inputLen (in bytes). |
final AlgorithmParameters |
getParameters() |
Returns the parameters used with this Cipher object. |
final Provider |
getProvider() |
Returns the provider of this Cipher object. |
final void |
init |
Initializes this Cipher object with the public key from the given certificate. |
final void |
init |
Initializes this Cipher object with the public key from the given certificate and a source of randomness. |
final void |
init |
Initializes this Cipher object with a key. |
final void |
init |
Initializes this Cipher object with a key and a set of algorithm parameters. |
final void |
init |
Initializes this Cipher object with a key, a set of algorithm parameters, and a source of randomness. |
final void |
init |
Initializes this Cipher object with a key and a source of randomness. |
final void |
init |
Initializes this Cipher object with a key and a set of algorithm parameters. |
final void |
init |
Initializes this Cipher object with a key, a set of algorithm parameters, and a source of randomness. |
String |
toString() |
Returns a String representation of this Cipher object. |
final Key |
unwrap |
Unwrap a previously wrapped key. |
final byte[] |
update |
Continues a multiple-part encryption or decryption operation (depending on how this Cipher object was initialized), processing another data part. |
final byte[] |
update |
Continues a multiple-part encryption or decryption operation (depending on how this Cipher object was initialized), processing another data part. |
final int |
update |
Continues a multiple-part encryption or decryption operation (depending on how this Cipher object was initialized), processing another data part. |
final int |
update |
Continues a multiple-part encryption or decryption operation (depending on how this Cipher object was initialized), processing another data part. |
final int |
update |
Continues a multiple-part encryption or decryption operation (depending on how this Cipher object was initialized), processing another data part. |
final void |
updateAAD |
Continues a multi-part update of the Additional Authentication Data (AAD). |
final void |
updateAAD |
Continues a multi-part update of the Additional Authentication Data (AAD), using a subset of the provided buffer. |
final void |
updateAAD |
Continues a multi-part update of the Additional Authentication Data (AAD). |
final byte[] |
wrap |
Wrap a key. |
Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | Modifier and Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
Indicates whether some other object is "equal to" this one. |
protected void |
finalize() |
Deprecated, for removal: This API element is subject to removal in a future version. Finalization is deprecated and subject to removal in a future release. |
final Class |
getClass() |
Returns the runtime class of this Object. |
int |
hashCode() |
Returns a hash code value for this object. |
final void |
notify() |
Wakes up a single thread that is waiting on this object's monitor. |
final void |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
final void |
wait() |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
final void |
wait |
Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed. |
Constructor Details
NullCipher
public NullCipher()
Creates a
NullCipher object.
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.