- java.lang.Object
-
- org.refcodes.security.alt.chaos.ChaosEncrypter
-
- All Implemented Interfaces:
org.refcodes.mixin.Disposable
,org.refcodes.security.Encrypter<byte[],byte[],org.refcodes.security.EncryptionException>
public class ChaosEncrypter extends Object implements org.refcodes.security.Encrypter<byte[],byte[],org.refcodes.security.EncryptionException>
TheChaosEncrypter
will use byte arrays as input and output types.
-
-
Constructor Summary
Constructors Modifier Constructor Description ChaosEncrypter(ChaosKey aKey)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting.ChaosEncrypter(ChaosKey aKey, boolean isVerify)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting.ChaosEncrypter(ChaosKey aKey, int aChildDepth)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting.ChaosEncrypter(ChaosKey aKey, int aChildDepth, boolean isVerify)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting.protected
ChaosEncrypter(ChaosKey aKey, int aChildDepth, ChaosEncrypter aChildEncrypter, boolean isVerify)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting and the givenChaosEncrypter
as child encrypter: TheChaosKey
must therefore have no childChaosKey
as the childChaosEncrypter
then cannot unambiguously be determined!
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
int
encrypt(byte[] aBuffer)
int
encrypt(byte[] aBuffer, int aOffset, int aLength)
byte[]
toEncrypted(byte[] aDecrypted)
int
toEncrypted(byte[] aBuffer, int aOffset, int aLength, byte[] aOutBuffer, int aOutOffset)
String
toString()
-
-
-
Constructor Detail
-
ChaosEncrypter
public ChaosEncrypter(ChaosKey aKey)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting.- Parameters:
aKey
- TheChaosKey
to use for encrypting.
-
ChaosEncrypter
public ChaosEncrypter(ChaosKey aKey, int aChildDepth)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting.- Parameters:
aKey
- TheChaosKey
to use for encrypting.aChildDepth
- The number of children to consider when creating theChaosDecrypter
.
-
ChaosEncrypter
public ChaosEncrypter(ChaosKey aKey, boolean isVerify)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting.- Parameters:
aKey
- TheChaosKey
to use for encrypting.isVerify
- When true then the encryption is verified against an according live decryption to throw anIllegalStateException
in case encryption and decryption differ.
-
ChaosEncrypter
public ChaosEncrypter(ChaosKey aKey, int aChildDepth, boolean isVerify)
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting.- Parameters:
aKey
- TheChaosKey
to use for encrypting.aChildDepth
- The number of children to consider when creating theChaosDecrypter
.isVerify
- When true then the encryption is verified against an according live decryption to throw anIllegalStateException
in case encryption and decryption differ.
-
ChaosEncrypter
protected ChaosEncrypter(ChaosKey aKey, int aChildDepth, ChaosEncrypter aChildEncrypter, boolean isVerify) throws IllegalArgumentException
Instantiates a newChaosEncrypter
using the givenChaosKey
for encrypting and the givenChaosEncrypter
as child encrypter: TheChaosKey
must therefore have no childChaosKey
as the childChaosEncrypter
then cannot unambiguously be determined! Attention: This constructor usually only is used by libraries which retrieve the various keys in different processing steps (seeChaosEncryptionOutputStream
).- Parameters:
aKey
- TheChaosKey
to use for encrypting.aChildDepth
- The number of children to consider when creating theChaosDecrypter
.aChildEncrypter
- TheChaosEncrypter
to be used as child encrypter.isVerify
- When true then the encryption is verified against an according live decryption to throw anIllegalStateException
in case encryption and decryption differ.- Throws:
IllegalArgumentException
- thrown in case the chaos key has a child key and a child encrypter is provided as well (either the one or the other only is allowed).
-
-
Method Detail
-
toEncrypted
public byte[] toEncrypted(byte[] aDecrypted) throws org.refcodes.security.EncryptionException
- Specified by:
toEncrypted
in interfaceorg.refcodes.security.Encrypter<byte[],byte[],org.refcodes.security.EncryptionException>
- Throws:
org.refcodes.security.EncryptionException
-
toEncrypted
public int toEncrypted(byte[] aBuffer, int aOffset, int aLength, byte[] aOutBuffer, int aOutOffset) throws org.refcodes.security.EncryptionException
- Specified by:
toEncrypted
in interfaceorg.refcodes.security.Encrypter<byte[],byte[],org.refcodes.security.EncryptionException>
- Throws:
org.refcodes.security.EncryptionException
-
encrypt
public int encrypt(byte[] aBuffer, int aOffset, int aLength) throws org.refcodes.security.EncryptionException
- Specified by:
encrypt
in interfaceorg.refcodes.security.Encrypter<byte[],byte[],org.refcodes.security.EncryptionException>
- Throws:
org.refcodes.security.EncryptionException
-
encrypt
public int encrypt(byte[] aBuffer) throws org.refcodes.security.EncryptionException
- Specified by:
encrypt
in interfaceorg.refcodes.security.Encrypter<byte[],byte[],org.refcodes.security.EncryptionException>
- Throws:
org.refcodes.security.EncryptionException
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-
-