Class 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>
    The ChaosDecrypter will use byte arrays as input and output types.
    • Constructor Detail

      • ChaosDecrypter

        public ChaosDecrypter​(char[] aSecret)
        Instantiates a new ChaosDecrypter by calculating x0, a and s from the provided char array.
        Parameters:
        aSecret - The char array (in contrast to a String, 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 new ChaosDecrypter by calculating x0, a and s from the provided String.
        Parameters:
        aSecret - The String from which to calculate x0, a and s.
      • ChaosDecrypter

        public ChaosDecrypter​(double x0,
                              double a,
                              long s)
        Instantiates a new ChaosDecrypter 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 new ChaosDecrypter from the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructor ChaosDecrypter(double, double, long). You can use values in the range of Integer.MIN_VALUE and Integer.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 new ChaosDecrypter from the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructor ChaosDecrypter(double, double, long). You can use values in the range of Integer.MIN_VALUE and Integer.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 - The ChaosMode (ChaosOptions) to use to enhance Chaos-based encryption.
      • ChaosDecrypter

        public ChaosDecrypter​(char[] aSecret,
                              ChaosOptions aChaosOptions)
        Instantiates a new ChaosDecrypter by calculating x0, a and s from the provided char array.
        Parameters:
        aSecret - The char array (in contrast to a String, 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 - The ChaosMode (ChaosOptions) to use to enhance Chaos-based encryption.
      • ChaosDecrypter

        public ChaosDecrypter​(String aSecret,
                              ChaosOptions aChaosOptions)
        Instantiates a new ChaosDecrypter by calculating x0, a and s from the provided String.
        Parameters:
        aSecret - The String from which to calculate x0, a and s.
        aChaosOptions - The ChaosMode (ChaosOptions) to use to enhance Chaos-based encryption.
      • ChaosDecrypter

        public ChaosDecrypter​(double x0,
                              double a,
                              long s,
                              ChaosOptions aChaosOptions)
        Instantiates a new ChaosDecrypter 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 - The ChaosMode (ChaosOptions) to use to enhance Chaos-based encryption.
    • Method Detail

      • toDecrypted

        public byte[] toDecrypted​(byte[] aEncrypted)
                           throws org.refcodes.security.DecryptionException
        Specified by:
        toDecrypted in interface org.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 interface org.refcodes.security.Decrypter<byte[],​byte[],​org.refcodes.security.DecryptionException>
        Throws:
        org.refcodes.security.DecryptionException
      • dispose

        public void dispose()
        Specified by:
        dispose in interface org.refcodes.mixin.Disposable