Class BaseByteArrayEncryptor
java.lang.Object
io.github.astrapi69.mystic.crypt.core.AbstractCryptor<C,K,T>
io.github.astrapi69.mystic.crypt.core.AbstractEncryptor<Cipher,SecretKey,String>
io.github.astrapi69.mystic.crypt.core.AbstractByteArrayEncryptor
io.github.astrapi69.mystic.crypt.base.BaseByteArrayEncryptor
- All Implemented Interfaces:
io.github.astrapi69.crypt.api.ByteArrayEncryptor
,io.github.astrapi69.crypt.api.Cryptor
,io.github.astrapi69.crypt.api.Encryptor<byte[],
,byte[]> Serializable
The class
BaseByteArrayEncryptor
can encrypt a byte array with his symmetric key- See Also:
-
Field Summary
Fields inherited from class io.github.astrapi69.mystic.crypt.core.AbstractCryptor
model
-
Constructor Summary
ConstructorDescriptionBaseByteArrayEncryptor
(io.github.astrapi69.crypt.data.model.CryptModel<Cipher, SecretKey, String> model) Instantiates a newBaseByteArrayEncryptor
with the givenCryptModel
objectBaseByteArrayEncryptor
(SecretKey symmetricKey) Instantiates a newBaseByteArrayEncryptor
with the givenSecretKey
object -
Method Summary
Methods inherited from class io.github.astrapi69.mystic.crypt.core.AbstractEncryptor
newOperationMode
Methods inherited from class io.github.astrapi69.mystic.crypt.core.AbstractCryptor
getModel, newAlgorithm, newAlgorithmParameterSpec, newCipher, newCipher, newCipher, newIterationCount, newKeySpec, newSalt, newSecretKeyFactory, onInitialize
-
Constructor Details
-
BaseByteArrayEncryptor
public BaseByteArrayEncryptor(io.github.astrapi69.crypt.data.model.CryptModel<Cipher, SecretKey, throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidAlgorithmParameterException, UnsupportedEncodingExceptionString> model) Instantiates a newBaseByteArrayEncryptor
with the givenCryptModel
object- Parameters:
model
- The crypt model- Throws:
InvalidAlgorithmParameterException
- is thrown if initialization of the cipher object fails.NoSuchPaddingException
- is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException
- is thrown if generation of the SecretKey object fails.NoSuchAlgorithmException
- is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeyException
- is thrown if initialization of the cipher object fails.NoSuchAlgorithmException
- is thrown if instantiation of the SecretKeyFactory object fails.UnsupportedEncodingException
- is thrown if the named charset is not supported.
-
BaseByteArrayEncryptor
public BaseByteArrayEncryptor(SecretKey symmetricKey) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidAlgorithmParameterException, UnsupportedEncodingException Instantiates a newBaseByteArrayEncryptor
with the givenSecretKey
object- Parameters:
symmetricKey
- The symmetric key.- Throws:
InvalidAlgorithmParameterException
- is thrown if initialization of the cipher object fails.NoSuchPaddingException
- is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException
- is thrown if generation of the SecretKey object fails.NoSuchAlgorithmException
- is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeyException
- is thrown if initialization of the cipher object fails.NoSuchAlgorithmException
- is thrown if instantiation of the SecretKeyFactory object fails.UnsupportedEncodingException
- is thrown if the named charset is not supported.
-
-
Method Details
-
encrypt
-
newCipher
protected Cipher newCipher(SecretKey key, String algorithm, byte[] salt, int iterationCount, int operationMode) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, UnsupportedEncodingException Factory method for creating a newCipher
from the given parameters. This method is invoked in the constructor from the derived classes and can be overridden so users can provide their own version of a newCipher
from the given parameters.- Specified by:
newCipher
in classAbstractCryptor<Cipher,
SecretKey, String> - Parameters:
key
- the keyalgorithm
- the algorithmsalt
- the salt.iterationCount
- the iteration countoperationMode
- the operation mode for the new cipher object- Returns:
- the cipher
- Throws:
NoSuchAlgorithmException
- is thrown if instantiation of the SecretKeyFactory object fails.InvalidKeySpecException
- is thrown if generation of the SecretKey object fails.NoSuchPaddingException
- is thrown if instantiation of the cipher object fails.InvalidKeyException
- is thrown if initialization of the cipher object fails.InvalidAlgorithmParameterException
- is thrown if initialization of the cipher object fails.UnsupportedEncodingException
- is thrown if the named charset is not supported.
-