AI-generated Key Takeaways
-
The
NullCipher
class in Java cryptography provides an "identity cipher" that does not transform plaintext, resulting in ciphertext identical to the plaintext. -
It acts as a pass-through, with initialization methods having no effect and a block size of 1 byte.
-
All encryption and decryption operations performed by
NullCipher
effectively return the original input data without any modifications. -
It inherits various constants and methods from the
javax.crypto.Cipher
class for compatibility but overrides them to maintain its identity transformation behavior. -
Developers might utilize
NullCipher
in scenarios where encryption is not desired but a Cipher object is required by an API or framework, or for testing and debugging purposes.
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.
Inherited Constant Summary
int | DECRYPT_MODE | Constant used to initialize cipher to decryption mode. |
int | ENCRYPT_MODE | Constant used to initialize cipher to encryption mode. |
int | PRIVATE_KEY | Constant used to indicate the to-be-unwrapped key is a "private key". |
int | PUBLIC_KEY | Constant used to indicate the to-be-unwrapped key is a "public key". |
int | SECRET_KEY | Constant used to indicate the to-be-unwrapped key is a "secret key". |
int | UNWRAP_MODE | Constant used to initialize cipher to key-unwrapping mode. |
int | WRAP_MODE | Constant used to initialize cipher to key-wrapping mode. |
Public Constructor Summary
NullCipher()
Creates a NullCipher object.
|
Inherited Method Summary
final int |
doFinal(byte[] input, int inputOffset, int inputLen, byte[] output)
Encrypts or decrypts data in a single-part operation, or finishes a
multiple-part operation.
|
final int |
doFinal(byte[] output, int outputOffset)
Finishes a multiple-part encryption or decryption operation, depending
on how this cipher was initialized.
|
final byte[] |
doFinal()
Finishes a multiple-part encryption or decryption operation, depending
on how this cipher was initialized.
|
final byte[] |
doFinal(byte[] input)
Encrypts or decrypts data in a single-part operation, or finishes a
multiple-part operation.
|
final int |
doFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
Encrypts or decrypts data in a single-part operation, or finishes a
multiple-part operation.
|
final int |
doFinal(ByteBuffer input, ByteBuffer output)
Encrypts or decrypts data in a single-part operation, or finishes a
multiple-part operation.
|
final byte[] |
doFinal(byte[] input, int inputOffset, int inputLen)
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.
|
final byte[] |
getIV()
Returns the initialization vector (IV) in a new buffer.
|
final static Cipher |
getInstance(String transformation)
Returns a
Cipher object that implements the specified
transformation. |
final static Cipher |
getInstance(String transformation, String provider)
Returns a
Cipher object that implements the specified
transformation. |
final static Cipher |
getInstance(String transformation, Provider provider)
Returns a
Cipher object that implements the specified
transformation. |
final static int |
getMaxAllowedKeyLength(String transformation)
Returns the maximum key length for the specified transformation
according to the installed JCE jurisdiction policy files.
|
final static AlgorithmParameterSpec |
getMaxAllowedParameterSpec(String transformation)
Returns an AlgorithmParameterSpec object which contains
the maximum cipher parameter value according to the
jurisdiction policy file.
|
final int |
getOutputSize(int inputLen)
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.
|
final Provider |
getProvider()
Returns the provider of this
Cipher object. |
final void |
init(int opmode, Key key, AlgorithmParameters params)
Initializes this cipher with a key and a set of algorithm
parameters.
|
final void |
init(int opmode, Certificate certificate, SecureRandom random)
Initializes this cipher with the public key from the given certificate
and
a source of randomness.
|
final void |
init(int opmode, Key key, SecureRandom random)
Initializes this cipher with a key and a source of randomness.
|
final void |
init(int opmode, Key key, AlgorithmParameterSpec params)
Initializes this cipher with a key and a set of algorithm
parameters.
|
final void | |
final void |
init(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random)
Initializes this cipher with a key, a set of algorithm
parameters, and a source of randomness.
|
final void |
init(int opmode, Certificate certificate)
Initializes this cipher with the public key from the given certificate.
|
final void |
init(int opmode, Key key, AlgorithmParameters params, SecureRandom random)
Initializes this cipher with a key, a set of algorithm
parameters, and a source of randomness.
|
final Key | |
final byte[] |
update(byte[] input)
Continues a multiple-part encryption or decryption operation
(depending on how this cipher was initialized), processing another data
part.
|
final int |
update(byte[] input, int inputOffset, int inputLen, byte[] output)
Continues a multiple-part encryption or decryption operation
(depending on how this cipher was initialized), processing another data
part.
|
final byte[] |
update(byte[] input, int inputOffset, int inputLen)
Continues a multiple-part encryption or decryption operation
(depending on how this cipher was initialized), processing another data
part.
|
final int |
update(ByteBuffer input, ByteBuffer output)
Continues a multiple-part encryption or decryption operation
(depending on how this cipher was initialized), processing another data
part.
|
final int |
update(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset)
Continues a multiple-part encryption or decryption operation
(depending on how this cipher was initialized), processing another data
part.
|
final void |
updateAAD(byte[] src, int offset, int len)
Continues a multi-part update of the Additional Authentication
Data (AAD), using a subset of the provided buffer.
|
final void |
updateAAD(ByteBuffer src)
Continues a multi-part update of the Additional Authentication
Data (AAD).
|
final void |
updateAAD(byte[] src)
Continues a multi-part update of the Additional Authentication
Data (AAD).
|
final byte[] |
Object |
clone()
Creates and returns a copy of this
Object . |
boolean | |
void |
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final Class<?> | |
int |
hashCode()
Returns an integer hash code for this object.
|
final void |
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the
wait() methods) to be woken up. |
final void |
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the
wait() methods) to be woken up. |
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final void |
wait(long timeout, int nanos)
Causes the calling thread to wait until another thread calls the
notify() or notifyAll() method of this object or until the
specified timeout expires. |
final void |
wait(long timeout)
Causes the calling thread to wait until another thread calls the
notify() or notifyAll() method of this object or until the
specified timeout expires. |
final void |
wait()
Causes the calling thread to wait until another thread calls the
notify() or notifyAll() method of this object. |
Public Constructors
public NullCipher ()
Creates a NullCipher object.