-
- All Superinterfaces:
AbstractGetNonceSize
,CryptoAlgorithm
,CryptoProcessor
- All Known Subinterfaces:
AbstractDecryptor
,AbstractEncryptor
,Decryptor
,Encryptor
- All Known Implementing Classes:
CryptorImplCipher
,CryptorImplCombined
,DecryptorImplCipher
,DecryptorImplCombined
,EncryptorImplCiper
,EncryptorImplCombined
public interface Cryptor extends CryptoProcessor, AbstractGetNonceSize
The abstract interface for an encryption or decryption function of an cryptographic algorithm. It supports bothsymmetric
as well asasymmetric
encryption. Implementations are typically just wrappers ofCipher
. However this API is much more flexible, safe, and avoids many pitfalls. E.g. multipleCipher
s can be combined without the need to change the code using theCryptor
.- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
- See Also:
Decryptor
,Encryptor
,CryptorFactory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default byte[]
crypt(byte[] input, boolean complete)
byte[]
crypt(byte[] input, int offset, int length, boolean complete)
default byte[]
crypt(CryptoBinary input, boolean complete)
default byte[]
doFinal()
default byte[]
process(byte[] input, int offset, int length, boolean complete)
Generic method to process and transform data.-
Methods inherited from interface io.github.mmm.crypto.crypt.AbstractGetNonceSize
getNonceSize
-
Methods inherited from interface io.github.mmm.crypto.algorithm.CryptoAlgorithm
getAlgorithm
-
Methods inherited from interface io.github.mmm.crypto.CryptoProcessor
process, process, process, reset
-
-
-
-
Method Detail
-
doFinal
default byte[] doFinal()
- Returns:
- the encrypted (or decrypted) data. May be empty or
null
. - See Also:
Cipher.doFinal()
-
crypt
default byte[] crypt(byte[] input, boolean complete)
- Parameters:
input
- the next chunk of data to encrypt or decrypt.complete
- -true
to complete the encryption or decryption in case this is the last chunk of data,false
otherwise.- Returns:
- the encrypted or decrypted data.
- See Also:
Cipher.update(byte[])
,Cipher.doFinal(byte[])
-
crypt
default byte[] crypt(CryptoBinary input, boolean complete)
- Parameters:
input
- the next chunk of data to encrypt or decrypt.complete
- -true
to complete the encryption or decryption in case this is the last chunk of data,false
otherwise.- Returns:
- the encrypted or decrypted data.
- See Also:
Cipher.update(byte[])
,Cipher.doFinal(byte[])
-
crypt
byte[] crypt(byte[] input, int offset, int length, boolean complete)
- Parameters:
input
- the next chunk of data to encrypt or decrypt.offset
- the offset where to start in theinput
array.length
- the number of bytes to read from theinput
array.complete
- -true
to complete the encryption or decryption in case this is the last chunk of data,false
otherwise.- Returns:
- the number of bytes that have been written into the
output
array. - See Also:
Cipher.update(byte[], int, int)
,Cipher.doFinal(byte[], int, int)
-
process
default byte[] process(byte[] input, int offset, int length, boolean complete)
Description copied from interface:CryptoProcessor
Generic method to process and transform data.CryptoProcessor
Equivalent of process
(input, offset, length, complete)HashCreator
update
(input, offset, length); returnhash
(complete);Cryptor
return
crypt
(input, offset, length, true);SignatureSigner
update
(input, offset, length); returnsignAfterUpdate
(complete);SignatureVerifier
throw new
UnsupportedOperationException
();- Specified by:
process
in interfaceCryptoProcessor
- Parameters:
input
- the data to process.offset
- the index where to start reading data frominput
.length
- the number of bytes to read frominput
.complete
- -true
to complete/reset this processor after processing the giveninput
,false
otherwise.- Returns:
- the transformed
input
data.
-
-