public final class GenericEncryptionAlgorithm extends Object implements EncryptionAlgorithm
Main implementation for encryption algorithms that have all logic based on passed EncryptionEngine.
The logic is based on whether it is intended for use with or without initialization vector.
EncryptionEngine and optionally does encoding/decoding
operations.ByteArrayFactory and includes in every
message based on used CombiningSplitting. This allows to use one instance for different messages (otherwise
it would not be safe to use same combination of key and IV for every message).This class is immutable and can be considered thread safe. It is not allowed to extend this class to ensure it stays that way.
| Modifier | Constructor and Description |
|---|---|
protected |
GenericEncryptionAlgorithm(EncryptionEngine engine,
BytesRepresentation bytesRepresentation,
String encoding)
Creates a new instance of generic algorithm that does NOT use initialization vector.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decrypt(byte[] input)
Decrypts specified array of bytes.
|
String |
decrypt(String input)
Decrypts specified input text using default UTF-8 encoding.
|
byte[] |
encrypt(byte[] input)
Encrypts specified array of bytes.
|
String |
encrypt(String input)
Encrypts specified input text.
|
protected GenericEncryptionAlgorithm(EncryptionEngine engine, BytesRepresentation bytesRepresentation, String encoding) throws EncryptionException
engine - engine for encryptionbytesRepresentation - representation of byte arrays in Stringencoding - encoding used for stringsEncryptionException - exception when algorithm cannot be createdpublic byte[] encrypt(byte[] input)
throws EncryptionException
EncryptionAlgorithmencrypt in interface EncryptionAlgorithminput - input bytes to be encryptedEncryptionException - possible exception when encryption failspublic String encrypt(String input) throws EncryptionException
EncryptionAlgorithmencrypt in interface EncryptionAlgorithminput - input text to be encryptedEncryptionException - possible exception when encryption failspublic byte[] decrypt(byte[] input)
throws EncryptionException
EncryptionAlgorithmdecrypt in interface EncryptionAlgorithminput - input bytes to be decryptedEncryptionException - possible exception when decryption failspublic String decrypt(String input) throws EncryptionException
EncryptionAlgorithmdecrypt in interface EncryptionAlgorithminput - input text to be decryptedEncryptionException - possible exception when decryption failsCopyright © 2019. All rights reserved.