- java.lang.Object
-
- org.refcodes.security.alt.chaos.ChaosDecrypter
-
- All Implemented Interfaces:
org.refcodes.mixin.Disposable
,org.refcodes.security.Decrypter<byte[],byte[],org.refcodes.security.DecryptionException>
public class ChaosDecrypter extends Object implements org.refcodes.security.Decrypter<byte[],byte[],org.refcodes.security.DecryptionException>
TheChaosDecrypter
will use byte arrays as input and output types.
-
-
Constructor Summary
Constructors Modifier Constructor Description ChaosDecrypter(char[] aSecret)
Instantiates a newChaosDecrypter
by calculating x0, a and s from the provided char array.ChaosDecrypter(char[] aSecret, ChaosOptions aChaosOptions)
Instantiates a newChaosDecrypter
by calculating x0, a and s from the provided char array.ChaosDecrypter(double x0, double a, long s)
Instantiates a newChaosDecrypter
directly from the provided double values.ChaosDecrypter(double x0, double a, long s, ChaosOptions aChaosOptions)
Instantiates a newChaosDecrypter
directly from the provided double values.ChaosDecrypter(int x0, int a, int s)
Instantiates a newChaosDecrypter
from the provided integer values.ChaosDecrypter(int x0, int a, int s, ChaosOptions aChaosOptions)
Instantiates a newChaosDecrypter
from the provided integer values.ChaosDecrypter(String aSecret)
Instantiates a newChaosDecrypter
by calculating x0, a and s from the providedString
.ChaosDecrypter(String aSecret, ChaosOptions aChaosOptions)
Instantiates a newChaosDecrypter
by calculating x0, a and s from the providedString
.ChaosDecrypter(ChaosKey aKey)
Instantiates a newChaosDecrypter
using the givenChaosKey
for decrypting.protected
ChaosDecrypter(ChaosKey aKey, ChaosDecrypter aChildDecrypter)
Instantiates a newChaosDecrypter
using the givenChaosKey
for encrypting and the givenChaosDecrypter
as _child encrypter: TTheChaosKey
must therefore have no childChaosKey
as the childChaosDecrypter
then cannot unambiguously be determined!
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
byte[]
toDecrypted(byte[] aEncrypted)
int
toDecrypted(byte[] aBuffer, int aOffset, int aLength, byte[] aOutBuffer, int aOutOffset)
String
toString()
-
-
-
Constructor Detail
-
ChaosDecrypter
public ChaosDecrypter(char[] aSecret)
Instantiates a newChaosDecrypter
by calculating x0, a and s from the provided char array.- Parameters:
aSecret
- The char array (in contrast to aString
, a char array can be invalidated after use by overwriting its array elements with random values) from which to calculate x0, a and s.
-
ChaosDecrypter
public ChaosDecrypter(String aSecret)
Instantiates a newChaosDecrypter
by calculating x0, a and s from the providedString
.- Parameters:
aSecret
- TheString
from which to calculate x0, a and s.
-
ChaosDecrypter
public ChaosDecrypter(double x0, double a, long s)
Instantiates a newChaosDecrypter
directly from the provided double values. Make sure your provided arguments are within the allowed bounds;- Parameters:
x0
- the x0: (0 <= x0 <= 1 )a
- the a: (a <= 3.57 <= 4 )s
- the s: (Integer.MAX_VALUE
>= s >=Integer.MAX_VALUE
AND 16 <= s <= -16)
-
ChaosDecrypter
public ChaosDecrypter(int x0, int a, int s)
Instantiates a newChaosDecrypter
from the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructorChaosDecrypter(double, double, long)
. You can use values in the range ofInteger.MIN_VALUE
andInteger.MAX_VALUE
.- Parameters:
x0
- The value from which to calculate the valid x0 double.a
- The value from which to calculate the valid a double.s
- The value from which to calculate the valid s double.
-
ChaosDecrypter
public ChaosDecrypter(int x0, int a, int s, ChaosOptions aChaosOptions)
Instantiates a newChaosDecrypter
from the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructorChaosDecrypter(double, double, long)
. You can use values in the range ofInteger.MIN_VALUE
andInteger.MAX_VALUE
.- Parameters:
x0
- The value from which to calculate the valid x0 double.a
- The value from which to calculate the valid a double.s
- The value from which to calculate the valid s double.aChaosOptions
- TheChaosMode
(ChaosOptions
) to use to enhance Chaos-based encryption.
-
ChaosDecrypter
public ChaosDecrypter(char[] aSecret, ChaosOptions aChaosOptions)
Instantiates a newChaosDecrypter
by calculating x0, a and s from the provided char array.- Parameters:
aSecret
- The char array (in contrast to aString
, a char array can be invalidated after use by overwriting its array elements with random values) from which to calculate x0, a and s.aChaosOptions
- TheChaosMode
(ChaosOptions
) to use to enhance Chaos-based encryption.
-
ChaosDecrypter
public ChaosDecrypter(String aSecret, ChaosOptions aChaosOptions)
Instantiates a newChaosDecrypter
by calculating x0, a and s from the providedString
.- Parameters:
aSecret
- TheString
from which to calculate x0, a and s.aChaosOptions
- TheChaosMode
(ChaosOptions
) to use to enhance Chaos-based encryption.
-
ChaosDecrypter
public ChaosDecrypter(double x0, double a, long s, ChaosOptions aChaosOptions)
Instantiates a newChaosDecrypter
directly from the provided double values. Make sure your provided arguments are within the allowed bounds;- Parameters:
x0
- the x0: (0 <= x0 <= 1 )a
- the a: (a <= 3.57 <= 4 )s
- the s: (Integer.MAX_VALUE
>= s >=Integer.MAX_VALUE
AND 16 <= s <= -16)aChaosOptions
- TheChaosMode
(ChaosOptions
) to use to enhance Chaos-based encryption.
-
ChaosDecrypter
public ChaosDecrypter(ChaosKey aKey)
Instantiates a newChaosDecrypter
using the givenChaosKey
for decrypting.- Parameters:
aKey
- TheChaosKey
to use for decrypting.
-
ChaosDecrypter
protected ChaosDecrypter(ChaosKey aKey, ChaosDecrypter aChildDecrypter) throws IllegalArgumentException
Instantiates a newChaosDecrypter
using the givenChaosKey
for encrypting and the givenChaosDecrypter
as _child encrypter: TTheChaosKey
must therefore have no childChaosKey
as the childChaosDecrypter
then cannot unambiguously be determined! Attention: This constructor usually only is used by libraries which retrieve the various keys in different processing steps (seeChaosDecryptionInputStream
).- Parameters:
aKey
- TheChaosKey
to use for decrypting.aChildDecrypter
- The childChaosDecrypter
to be used as child decrypter.- Throws:
IllegalArgumentException
- thrown in case the chaos key has a child key and a child decrypter is provided as well (either the one or the other only is allowed).
-
-
Method Detail
-
toDecrypted
public byte[] toDecrypted(byte[] aEncrypted) throws org.refcodes.security.DecryptionException
- Specified by:
toDecrypted
in interfaceorg.refcodes.security.Decrypter<byte[],byte[],org.refcodes.security.DecryptionException>
- Throws:
org.refcodes.security.DecryptionException
-
toDecrypted
public int toDecrypted(byte[] aBuffer, int aOffset, int aLength, byte[] aOutBuffer, int aOutOffset) throws org.refcodes.security.DecryptionException
- Specified by:
toDecrypted
in interfaceorg.refcodes.security.Decrypter<byte[],byte[],org.refcodes.security.DecryptionException>
- Throws:
org.refcodes.security.DecryptionException
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-
-