Class ChaosKeyImpl

  • All Implemented Interfaces:
    Serializable, Key, SecretKey, Destroyable, ChaosKey


    public class ChaosKeyImpl
    extends Object
    implements ChaosKey, SecretKey
    Thanks Christian Pontesegger for the very good example on "Writing your own JCA extensions - a full cipher" at: "http://codeandme.blogspot.de/2013/07/writing-your-own-jca-extensions-full.html" and for the very good example on "Writing your own JCA extensions - a simple digest " at: "http://codeandme.blogspot.de/2013/06/writing-your-own-jca-extensions-simple.html"
    See Also:
    Serialized Form
    • Constructor Detail

      • ChaosKeyImpl

        public ChaosKeyImpl​(String aSecret)
        Instantiates a new chaos key by calculating x0, a and s from the provided String.
        Parameters:
        aSecret - The String from which to calculate x0, a and s.
      • ChaosKeyImpl

        public ChaosKeyImpl​(int x0,
                            int a,
                            int s)
        Instantiates a new chaos key from the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructor ChaosKeyImpl(double, double, double). 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.
      • ChaosKeyImpl

        public ChaosKeyImpl​(double x0,
                            double a,
                            double s)
        Instantiates a new chaos key.
        Parameters:
        x0 - the x0: (0 <= x0 <= 1 )
        a - the a: (a <= 3.57 <= 4 )
        s - the s: (s > Integer.MAX_VALUE)
    • Method Detail

      • getEncoded

        public byte[] getEncoded​()
        Specified by:
        getEncoded in interface Key
      • getX0

        public double getX0​()
        Gets the x0.
        Specified by:
        getX0 in interface ChaosKey
        Returns:
        the x0
      • getA

        public double getA​()
        Gets the a.
        Specified by:
        getA in interface ChaosKey
        Returns:
        the a
      • getS

        public double getS​()
        Gets the s.
        Specified by:
        getS in interface ChaosKey
        Returns:
        the s
      • toX0

        protected static double toX0​(int x0)
        Creates a valid x0 double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
        Parameters:
        x0 - The integer as source for x0
        Returns:
        The x0 inside the valid scope.
      • toA

        protected static double toA​(int a)
        Creates a valid a double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
        Parameters:
        a - The integer as source for a
        Returns:
        The a inside the valid scope.
      • toS

        protected static double toS​(int s)
        Creates a valid s double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
        Parameters:
        s - The integer as source for s
        Returns:
        The s inside the valid scope.
      • validate

        protected static void validate​(double x0,
                                       double a,
                                       double s)
        Validates the given values whether them are in scope.
        Parameters:
        x0 - The x0 value to validate.
        a - The a value to validate.
        s - The s value to validate.