public final class CryptByteBuffer
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
CryptByteBuffer(CryptByteBufferType type,
byte[] key)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key.
|
CryptByteBuffer(CryptByteBufferType type,
byte[] key,
byte[] iv)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key and iv.
|
CryptByteBuffer(CryptByteBufferType type,
byte[] key,
byte[] iv,
int offset)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key and iv.
|
CryptByteBuffer(CryptByteBufferType type,
java.nio.ByteBuffer key)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key.
|
CryptByteBuffer(CryptByteBufferType type,
java.nio.ByteBuffer key,
java.nio.ByteBuffer iv)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key and iv.
|
CryptByteBuffer(CryptByteBufferType type,
javax.crypto.SecretKey key)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key.
|
CryptByteBuffer(CryptByteBufferType type,
javax.crypto.SecretKey key,
byte[] iv)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key and iv.
|
CryptByteBuffer(CryptByteBufferType type,
javax.crypto.SecretKey key,
byte[] iv,
int offset)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key and iv.
|
CryptByteBuffer(CryptByteBufferType type,
javax.crypto.SecretKey key,
java.nio.ByteBuffer iv)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key and iv.
|
CryptByteBuffer(CryptByteBufferType type,
javax.crypto.SecretKey key,
javax.crypto.spec.IvParameterSpec iv)
Creates an instance of CryptByteBuffer that will be able to encrypt and decrypt
sets of bytes using the specified algorithm type with the given key.
|
Modifier and Type | Method and Description |
---|---|
void |
decrypt(byte[] input,
int offset,
int len)
Decrypt the specified section of the provided byte[] in-place
|
void |
decrypt(byte[] input,
int offset,
int len,
byte[] output,
int outputOffset)
Decrypt the specified section of the provided byte[] to the output byte[], without
modifying the input.
|
void |
decrypt(java.nio.ByteBuffer input,
java.nio.ByteBuffer output)
Get bytes from one ByteBuffer and encrypt them and put them into the other ByteBuffer.
|
byte[] |
decryptCopy(byte[] input)
Decrypts the provided byte[].
|
byte[] |
decryptCopy(byte[] input,
int offset,
int len)
Decrypts the specified section of provided byte[] into an array which is returned as a
ByteBuffer.
|
java.nio.ByteBuffer |
decryptCopy(java.nio.ByteBuffer input)
Decrypts the provided ByteBuffer, returning a new ByteBuffer.
|
void |
encrypt(byte[] input,
int offset,
int len)
Encrypt the specified section of the provided byte[] in-place
|
void |
encrypt(byte[] input,
int offset,
int len,
byte[] output,
int outputOffset)
Encrypt the specified section of the provided byte[] to the output byte[], without
modifying the input.
|
void |
encrypt(java.nio.ByteBuffer input,
java.nio.ByteBuffer output)
Get bytes from one ByteBuffer and encrypt them and put them into the other ByteBuffer.
|
byte[] |
encryptCopy(byte[] input)
Encrypts the provided byte[].
|
byte[] |
encryptCopy(byte[] input,
int offset,
int len)
Encrypts the specified section of provided byte[] into a new array returned as a ByteBuffer.
|
java.nio.ByteBuffer |
encryptCopy(java.nio.ByteBuffer input)
Encrypts the provided ByteBuffer, returning a new ByteBuffer.
|
javax.crypto.spec.IvParameterSpec |
genIV()
Generates a new IV to be used and initializes the cipher instances with
the new iv.
|
javax.crypto.spec.IvParameterSpec |
getIV()
Gets the IV being used.
|
void |
setIV(javax.crypto.spec.IvParameterSpec iv)
Changes the current iv to the provided iv and initializes the cipher instances with
the new iv.
|
public CryptByteBuffer(CryptByteBufferType type, javax.crypto.SecretKey key, javax.crypto.spec.IvParameterSpec iv) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptioniv
- The iv that will be used for encryption.java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
public CryptByteBuffer(CryptByteBufferType type, javax.crypto.SecretKey key) throws java.security.GeneralSecurityException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptionjava.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
java.security.GeneralSecurityException
public CryptByteBuffer(CryptByteBufferType type, byte[] key) throws java.security.GeneralSecurityException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptionjava.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
java.security.GeneralSecurityException
public CryptByteBuffer(CryptByteBufferType type, java.nio.ByteBuffer key) throws java.security.GeneralSecurityException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptionjava.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
java.security.GeneralSecurityException
public CryptByteBuffer(CryptByteBufferType type, javax.crypto.SecretKey key, byte[] iv, int offset) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptioniv
- The byte[] containing the ivoffset
- Where in the byte[] the iv startsjava.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
public CryptByteBuffer(CryptByteBufferType type, javax.crypto.SecretKey key, byte[] iv) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptioniv
- The iv that will be used for encryption.java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
public CryptByteBuffer(CryptByteBufferType type, javax.crypto.SecretKey key, java.nio.ByteBuffer iv) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptioniv
- The iv that will be used for encryption.java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
public CryptByteBuffer(CryptByteBufferType type, byte[] key, byte[] iv, int offset) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptioniv
- The byte[] containing the ivoffset
- Where in the byte[] the iv startsjava.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException
public CryptByteBuffer(CryptByteBufferType type, byte[] key, byte[] iv) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptioniv
- The iv that will be used for encryption.java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
public CryptByteBuffer(CryptByteBufferType type, java.nio.ByteBuffer key, java.nio.ByteBuffer iv) throws java.security.InvalidKeyException, java.security.InvalidAlgorithmParameterException
type
- The symmetric algorithm, mode, and key and block size to usekey
- The key that will be used for encryptioniv
- The iv that will be used for encryption.java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyException
public void encrypt(byte[] input, int offset, int len, byte[] output, int outputOffset)
public void encrypt(byte[] input, int offset, int len)
public byte[] encryptCopy(byte[] input, int offset, int len)
input
- The bytes to be encrypted. Contents will not be modified.offset
- The position of input to start encrypting atlen
- The number of bytes after offset to encryptpublic byte[] encryptCopy(byte[] input)
input
- The byte[] to be encryptedpublic java.nio.ByteBuffer encryptCopy(java.nio.ByteBuffer input)
input
- The byte[] to be encryptedpublic void encrypt(java.nio.ByteBuffer input, java.nio.ByteBuffer output)
public void decrypt(byte[] input, int offset, int len, byte[] output, int outputOffset)
public void decrypt(byte[] input, int offset, int len)
public byte[] decryptCopy(byte[] input, int offset, int len)
input
- The bytes to be decrypted. Contents will not be modified.offset
- The position of input to start decrypting atlen
- The number of bytes after offset to decryptpublic byte[] decryptCopy(byte[] input)
input
- The byte[] to be decryptedpublic java.nio.ByteBuffer decryptCopy(java.nio.ByteBuffer input)
input
- The buffer to be decryptedpublic void decrypt(java.nio.ByteBuffer input, java.nio.ByteBuffer output)
public void setIV(javax.crypto.spec.IvParameterSpec iv) throws java.security.InvalidAlgorithmParameterException
iv
- The new iv to use as IvParameterSpecjava.security.InvalidAlgorithmParameterException
public javax.crypto.spec.IvParameterSpec genIV()
public javax.crypto.spec.IvParameterSpec getIV()