Class AbstractRandomStringGenerator

    • Field Detail

      • randomizer

        protected final java.security.SecureRandom randomizer
        An instance of secure random to ensure randomness is secure.
      • defaultLength

        protected final long defaultLength
        Default string length before encoding.
    • Constructor Detail

      • AbstractRandomStringGenerator

        protected AbstractRandomStringGenerator()
        Instantiates a new default random string generator with length set to RandomStringGenerator.DEFAULT_LENGTH.
    • Method Detail

      • getAlgorithm

        public java.lang.String getAlgorithm()
        Description copied from interface: RandomStringGenerator
        The algorithm used by the generator's SecureRandom instance.
        Specified by:
        getAlgorithm in interface RandomStringGenerator
        Returns:
        the algorithm used by the generator's SecureRandom instance.
      • convertBytesToString

        protected java.lang.String convertBytesToString​(byte[] random)
        Converts byte[] to String by simple cast. Subclasses should override.
        Parameters:
        random - raw bytes
        Returns:
        a converted String
      • getNewString

        public java.lang.String getNewString​(int size)
        Description copied from interface: RandomStringGenerator
        A new random string of specified initial size.
        Specified by:
        getNewString in interface RandomStringGenerator
        Parameters:
        size - length of random string before encoding
        Returns:
        a new random string of specified initial size
      • getNewString

        public java.lang.String getNewString()
        Description copied from interface: RandomStringGenerator
        A new random string of specified default size.
        Specified by:
        getNewString in interface RandomStringGenerator
        Returns:
        a new random string of default initial size
      • getNewStringAsBytes

        public byte[] getNewStringAsBytes​(int size)
        Description copied from interface: RandomStringGenerator
        Gets the new string as bytes.
        Specified by:
        getNewStringAsBytes in interface RandomStringGenerator
        Parameters:
        size - the size of return
        Returns:
        the new random string as bytes