public final class AES
extends java.lang.Object
encrypt(int, java.lang.String, java.io.InputStream, java.io.OutputStream)
and decrypt(java.lang.String, java.io.InputStream, java.io.OutputStream)
, which encrypt and decrypt arbitrary
streams of data, respectively.Modifier and Type | Class and Description |
---|---|
static class |
AES.InvalidAESStreamException
Thrown if an attempt is made to decrypt an invalid AES stream.
|
static class |
AES.InvalidKeyLengthException
Thrown if an attempt is made to encrypt a stream with an invalid AES key length.
|
static class |
AES.InvalidPasswordException
Thrown if an attempt is made to decrypt a stream with an incorrect password.
|
static class |
AES.StrongEncryptionNotAvailableException
Thrown if 192- or 256-bit AES encryption or decryption is attempted,
but not available on the particular Java platform.
|
Constructor and Description |
---|
AES() |
Modifier and Type | Method and Description |
---|---|
static NamedContainer<java.lang.Integer,java.lang.String> |
decrypt(java.lang.String password,
byte[] input)
Decrypts a stream of data that was encrypted by
encrypt(int, java.lang.String, java.io.InputStream, java.io.OutputStream) . |
static int |
decrypt(java.lang.String password,
java.io.InputStream input,
java.io.OutputStream output)
Decrypts a stream of data that was encrypted by
encrypt(int, java.lang.String, java.io.InputStream, java.io.OutputStream) . |
static void |
encrypt(int keyLength,
java.lang.String password,
java.io.InputStream input,
java.io.OutputStream output)
Encrypts a stream of data.
|
static byte[] |
encrypt(int keyLength,
java.lang.String password,
java.lang.String input)
Encrypts a stream of data.
|
public static void encrypt(int keyLength, java.lang.String password, java.io.InputStream input, java.io.OutputStream output) throws AES.InvalidKeyLengthException, AES.StrongEncryptionNotAvailableException, java.io.IOException
keyLength
- key length to use for AES encryption (must be 128, 192, or 256)password
- password to use for encryptioninput
- an arbitrary byte stream to encryptoutput
- stream to which encrypted data will be writtenAES.InvalidKeyLengthException
- if keyLength is not 128, 192, or 256AES.StrongEncryptionNotAvailableException
- if keyLength is 192 or 256, but the Java runtime's jurisdiction
policy files do not allow 192- or 256-bit encryptionjava.io.IOException
public static byte[] encrypt(int keyLength, java.lang.String password, java.lang.String input) throws java.io.IOException, AES.StrongEncryptionNotAvailableException, AES.InvalidKeyLengthException
keyLength
- key length to use for AES encryption (must be 128, 192, or 256)password
- password to use for encryptioninput
- an arbitrary string to encryptAES.InvalidKeyLengthException
- if keyLength is not 128, 192, or 256AES.StrongEncryptionNotAvailableException
- if keyLength is 192 or 256, but the Java runtime's jurisdiction
policy files do not allow 192- or 256-bit encryptionjava.io.IOException
public static int decrypt(java.lang.String password, java.io.InputStream input, java.io.OutputStream output) throws AES.InvalidPasswordException, AES.InvalidAESStreamException, java.io.IOException, AES.StrongEncryptionNotAvailableException
encrypt(int, java.lang.String, java.io.InputStream, java.io.OutputStream)
.password
- the password used to encrypt/decrypt the streaminput
- stream of encrypted data to be decryptedoutput
- stream to which decrypted data will be writtenAES.InvalidPasswordException
- if the given password was not used to encrypt the dataAES.InvalidAESStreamException
- if the given input stream is not a valid AES-encrypted streamAES.StrongEncryptionNotAvailableException
- if the stream is 192 or 256-bit encrypted, and the Java runtime's
jurisdiction policy files do not allow for AES-192 or 256java.io.IOException
public static NamedContainer<java.lang.Integer,java.lang.String> decrypt(java.lang.String password, byte[] input) throws java.io.IOException, AES.StrongEncryptionNotAvailableException, AES.InvalidAESStreamException, AES.InvalidPasswordException
encrypt(int, java.lang.String, java.io.InputStream, java.io.OutputStream)
.password
- the password used to encrypt/decrypt the stringinput
- string of encrypted data to be decryptedAES.InvalidPasswordException
- if the given password was not used to encrypt the dataAES.InvalidAESStreamException
- if the given input stream is not a valid AES-encrypted streamAES.StrongEncryptionNotAvailableException
- if the stream is 192 or 256-bit encrypted, and the Java runtime's
jurisdiction policy files do not allow for AES-192 or 256java.io.IOException