javax.crypto
Stay organized with collections
Save and categorize content based on your preferences.
Interfaces
Classes
Cipher |
This class provides the functionality of a cryptographic cipher for
encryption and decryption. |
CipherInputStream |
A CipherInputStream is composed of an InputStream and a Cipher so
that read() methods return data that are read in from the
underlying InputStream but have been additionally processed by the
Cipher. |
CipherOutputStream |
A CipherOutputStream is composed of an OutputStream and a Cipher so
that write() methods first process the data before writing them out
to the underlying OutputStream. |
CipherSpi |
This class defines the Service Provider Interface (SPI)
for the Cipher class. |
ExemptionMechanism |
This class provides the functionality of an exemption mechanism, examples
of which are key recovery, key weakening, and
key escrow. |
ExemptionMechanismSpi |
This class defines the Service Provider Interface (SPI)
for the ExemptionMechanism class. |
KeyAgreement |
This class provides the functionality of a key agreement (or key
exchange) protocol. |
KeyAgreementSpi |
This class defines the Service Provider Interface (SPI)
for the KeyAgreement class. |
KeyGenerator |
This class provides the functionality of a secret (symmetric) key generator. |
KeyGeneratorSpi |
This class defines the Service Provider Interface (SPI)
for the KeyGenerator class. |
Mac |
This class provides the functionality of a "Message Authentication Code"
(MAC) algorithm. |
MacSpi |
This class defines the Service Provider Interface (SPI)
for the Mac class. |
NullCipher |
The NullCipher class is a class that provides an
"identity cipher" -- one that does not transform the plain text. |
SealedObject |
This class enables a programmer to create an object and protect its
confidentiality with a cryptographic algorithm. |
SecretKeyFactory |
This class represents a factory for secret keys. |
SecretKeyFactorySpi |
This class defines the Service Provider Interface (SPI)
for the SecretKeyFactory class. |
Exceptions
AEADBadTagException |
This exception is thrown when a Cipher operating in
an AEAD mode (such as GCM/CCM) is unable to verify the supplied
authentication tag. |
BadPaddingException |
This exception is thrown when a particular padding mechanism is
expected for the input data but the data is not padded properly. |
ExemptionMechanismException |
This is the generic ExemptionMechanism exception. |
IllegalBlockSizeException |
This exception is thrown when the length of data provided to a block
cipher is incorrect, i.e., does not match the block size of the cipher. |
NoSuchPaddingException |
This exception is thrown when a particular padding mechanism is
requested but is not available in the environment. |
ShortBufferException |
This exception is thrown when an output buffer provided by the user
is too short to hold the operation result. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eThe \u003ccode\u003ejavax.crypto\u003c/code\u003e package provides classes for cryptographic operations, including encryption, decryption, key generation, and message authentication.\u003c/p\u003e\n"],["\u003cp\u003eCore functionalities are exposed through key classes like \u003ccode\u003eCipher\u003c/code\u003e, \u003ccode\u003eKeyAgreement\u003c/code\u003e, \u003ccode\u003eKeyGenerator\u003c/code\u003e, \u003ccode\u003eMac\u003c/code\u003e, and \u003ccode\u003eSecretKeyFactory\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eCipher\u003c/code\u003e offers encryption and decryption capabilities, supporting various algorithms and modes of operation.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eKeyAgreement\u003c/code\u003e enables key exchange protocols for secure communication establishment.\u003c/p\u003e\n"],["\u003cp\u003eSeveral specialized exception classes handle cryptographic errors and exceptional conditions during operations.\u003c/p\u003e\n"]]],[],null,["Interfaces \n\n|-------------------------------------------------------------|---------------------------|\n| [SecretKey](../../../reference/javax/crypto/SecretKey.html) | A secret (symmetric) key. |\n\nClasses \n\n|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Cipher](../../../reference/javax/crypto/Cipher.html) | This class provides the functionality of a cryptographic cipher for encryption and decryption. |\n| [CipherInputStream](../../../reference/javax/crypto/CipherInputStream.html) | A CipherInputStream is composed of an InputStream and a Cipher so that read() methods return data that are read in from the underlying InputStream but have been additionally processed by the Cipher. |\n| [CipherOutputStream](../../../reference/javax/crypto/CipherOutputStream.html) | A CipherOutputStream is composed of an OutputStream and a Cipher so that write() methods first process the data before writing them out to the underlying OutputStream. |\n| [CipherSpi](../../../reference/javax/crypto/CipherSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `Cipher` class. |\n| [ExemptionMechanism](../../../reference/javax/crypto/ExemptionMechanism.html) | This class provides the functionality of an exemption mechanism, examples of which are *key recovery* , *key weakening* , and *key escrow*. |\n| [ExemptionMechanismSpi](../../../reference/javax/crypto/ExemptionMechanismSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `ExemptionMechanism` class. |\n| [KeyAgreement](../../../reference/javax/crypto/KeyAgreement.html) | This class provides the functionality of a key agreement (or key exchange) protocol. |\n| [KeyAgreementSpi](../../../reference/javax/crypto/KeyAgreementSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `KeyAgreement` class. |\n| [KeyGenerator](../../../reference/javax/crypto/KeyGenerator.html) | This class provides the functionality of a secret (symmetric) key generator. |\n| [KeyGeneratorSpi](../../../reference/javax/crypto/KeyGeneratorSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `KeyGenerator` class. |\n| [Mac](../../../reference/javax/crypto/Mac.html) | This class provides the functionality of a \"Message Authentication Code\" (MAC) algorithm. |\n| [MacSpi](../../../reference/javax/crypto/MacSpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `Mac` class. |\n| [NullCipher](../../../reference/javax/crypto/NullCipher.html) | The NullCipher class is a class that provides an \"identity cipher\" -- one that does not transform the plain text. |\n| [SealedObject](../../../reference/javax/crypto/SealedObject.html) | This class enables a programmer to create an object and protect its confidentiality with a cryptographic algorithm. |\n| [SecretKeyFactory](../../../reference/javax/crypto/SecretKeyFactory.html) | This class represents a factory for secret keys. |\n| [SecretKeyFactorySpi](../../../reference/javax/crypto/SecretKeyFactorySpi.html) | This class defines the *Service Provider Interface* (**SPI** ) for the `SecretKeyFactory` class. |\n\nExceptions \n\n|-------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [AEADBadTagException](../../../reference/javax/crypto/AEADBadTagException.html) | This exception is thrown when a [Cipher](../../../reference/javax/crypto/Cipher.html) operating in an AEAD mode (such as GCM/CCM) is unable to verify the supplied authentication tag. |\n| [BadPaddingException](../../../reference/javax/crypto/BadPaddingException.html) | This exception is thrown when a particular padding mechanism is expected for the input data but the data is not padded properly. |\n| [ExemptionMechanismException](../../../reference/javax/crypto/ExemptionMechanismException.html) | This is the generic ExemptionMechanism exception. |\n| [IllegalBlockSizeException](../../../reference/javax/crypto/IllegalBlockSizeException.html) | This exception is thrown when the length of data provided to a block cipher is incorrect, i.e., does not match the block size of the cipher. |\n| [NoSuchPaddingException](../../../reference/javax/crypto/NoSuchPaddingException.html) | This exception is thrown when a particular padding mechanism is requested but is not available in the environment. |\n| [ShortBufferException](../../../reference/javax/crypto/ShortBufferException.html) | This exception is thrown when an output buffer provided by the user is too short to hold the operation result. |"]]