Module org.refcodes.security
Package org.refcodes.security
Interface Encrypter<ENC,DEC,EXC extends EncryptionException>
- Type Parameters:
ENC
- The type of the encrypted data.DEC
- The type of the decrypted data.EXC
- The specific type of theEncryptionException
being thrown.
- All Superinterfaces:
org.refcodes.mixin.Disposable
- All Known Subinterfaces:
Crypter<ENC,
DEC, ENCEXC, DECEXC>
public interface Encrypter<ENC,DEC,EXC extends EncryptionException>
extends org.refcodes.mixin.Disposable
Plain interface for providing straight forward encryption functionality as of
toEncrypted(Object)
and for forcing your plain functionality to
provide a bridge to the Java Cryptographic Extension (JCE) framework's
CipherSpi
as of toEncrypted(byte[], int, int, byte[], int)
.
This way you can use your algorithms outside the JCE framework. This may be
necessary when your Java's security settings prevent running your own JCE
extensions from inside an (Oracle-) unsigned JAR.-
Method Summary
Modifier and TypeMethodDescriptiondefault int
encrypt
(byte[] aBuffer) This method encrypts the provided buffer.default int
encrypt
(byte[] aBuffer, int aOffset, int aLength) This method encrypts the provided buffer beginning at the given offset and the given number of bytes.int
toEncrypted
(byte[] aBuffer, int aOffset, int aLength, byte[] aOutBuffer, int aOutOffset) For compatibility with the java.security framework, ehttps://www.metacodes.proly to be integrated in a sub-class of theCipherSpi
.toEncrypted
(DEC aInput) You pass in data of a given type and you get encrypted data of (another) given type.Methods inherited from interface org.refcodes.mixin.Disposable
dispose
-
Method Details
-
toEncrypted
You pass in data of a given type and you get encrypted data of (another) given type.- Parameters:
aInput
- The input data to be encrypted.- Returns:
- The encrypted output data.
- Throws:
EXC
- Thrown in case something went wrong upon encryption.
-
toEncrypted
int toEncrypted(byte[] aBuffer, int aOffset, int aLength, byte[] aOutBuffer, int aOutOffset) throws EncryptionException For compatibility with the java.security framework, ehttps://www.metacodes.proly to be integrated in a sub-class of theCipherSpi
.- Parameters:
aBuffer
- The input to be encrypted.aOffset
- The offset to start encryption.aLength
- The length to be encryptedaOutBuffer
- The output where to encrypt to.aOutOffset
- The offset where to start writing the encrypted output.- Returns:
- The number of bytes encrypted.
- Throws:
EncryptionException
- Thrown in case an encryption issue occurred regarding theEncrypter
. Probably the configuration of yourEncrypter
does not fit the one of theDecrypter
.ArrayIndexOutOfBoundsException
- In case you provided lengths and offsets not fitting with the provided arrays.
-
encrypt
This method encrypts the provided buffer beginning at the given offset and the given number of bytes.- Parameters:
aBuffer
- The input to be encrypted.aOffset
- The offset to start encryption.aLength
- The length to be encrypted- Returns:
- The number of bytes encrypted.
- Throws:
EncryptionException
- Thrown in case a encryption issue occurred regarding theEncrypter
. Probably the configuration of yourEncrypter
does not fit the one of theEncrypter
.ArrayIndexOutOfBoundsException
- In case you provided lengths and offsets not fitting with the provided arrays.
-
encrypt
This method encrypts the provided buffer.- Parameters:
aBuffer
- The input to be encrypted.- Returns:
- The number of bytes encrypted.
- Throws:
EncryptionException
- Thrown in case a encryption issue occurred regarding theEncrypter
. Probably the configuration of yourEncrypter
does not fit the one of theEncrypter
.ArrayIndexOutOfBoundsException
- In case you provided lengths and offsets not fitting with the provided arrays.
-