public final class AES extends java.lang.Object implements Cipher
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(int keyLength)
Constructor for use as a SubData Cipher
|
Modifier and Type | Method and Description |
---|---|
org.json.JSONObject |
decrypt(java.lang.String key,
byte[] data)
This method calls to
decrypt(String, InputStream, OutputStream) ), simplified for the net.ME1312.SubServers.Bungee.Network.Cipher interface. |
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.
|
byte[] |
encrypt(java.lang.String key,
org.json.JSONObject data)
This method calls to
encrypt(int, String, InputStream, OutputStream) , simplified for the net.ME1312.SubServers.Bungee.Network.Cipher interface. |
java.lang.String |
getName()
Get the name of this Cipher
|
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 byte[] encrypt(java.lang.String key, org.json.JSONObject data) throws java.lang.Exception
encrypt(int, String, InputStream, OutputStream)
, simplified for the net.ME1312.SubServers.Bungee.Network.Cipher
interface.public java.lang.String getName()
Cipher
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 org.json.JSONObject decrypt(java.lang.String key, byte[] data) throws java.lang.Exception
decrypt(String, InputStream, OutputStream)
), simplified for the net.ME1312.SubServers.Bungee.Network.Cipher
interface.