Class DigestBuilder


  • public class DigestBuilder
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] build()
      Compute and return the digest.
      java.lang.String buildHexString()
      Compute and return the digest as a lower-case hex-encoded String.
      static DigestBuilder custom​(java.lang.String algorithm)  
      static DigestBuilder md5()  
      DigestBuilder reset()
      Manually reset the underlying MessageDigest.
      static DigestBuilder sha1()  
      static DigestBuilder sha256()  
      DigestBuilder update​(boolean input)
      Update the digest input with input.
      DigestBuilder update​(byte input)
      Update the digest input with input.
      DigestBuilder update​(byte[] input)
      Update the digest input with the bytes from the big-endian representation of each element of input.
      DigestBuilder update​(double input)
      Update the digest input with the bytes from the big-endian representation of input's raw long bits.
      DigestBuilder update​(double[] input)
      Update the digest input with the bytes from the big-endian representation of each element of input.
      DigestBuilder update​(float input)
      Update the digest input with the bytes from the big-endian representation of input's raw int bits.
      DigestBuilder update​(float[] input)
      Update the digest input with the bytes from the big-endian representation of each element of input.
      DigestBuilder update​(int input)
      Update the digest input with the bytes from the big-endian representation of input.
      DigestBuilder update​(int[] input)
      Update the digest input with the bytes from the big-endian representation of each element of input.
      DigestBuilder update​(long input)
      Update the digest input with the bytes from the big-endian representation of input.
      DigestBuilder update​(long[] input)
      Update the digest input with the bytes from the big-endian representation of each element of input.
      DigestBuilder update​(short input)
      Update the digest input with the bytes from the big-endian representation of input.
      DigestBuilder update​(short[] input)
      Update the digest input with the bytes from the big-endian representation of each element of input.
      DigestBuilder update​(java.lang.String input)
      Update the digest input with bytes from input in StandardCharsets.UTF_8 encoding.
      DigestBuilder update​(java.lang.String input, java.nio.charset.Charset charset)
      Update the digest input with bytes from input in charset encoding.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • custom

        public static DigestBuilder custom​(java.lang.String algorithm)
                                    throws java.security.NoSuchAlgorithmException
        Parameters:
        algorithm - the message digest algorithm.
        Returns:
        a DigestBuilder that uses algorithm.
        Throws:
        java.security.NoSuchAlgorithmException - if no message digest for algorithm is available.
      • update

        public DigestBuilder update​(java.lang.String input)
        Update the digest input with bytes from input in StandardCharsets.UTF_8 encoding.
        Parameters:
        input - the input String.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(java.lang.String input,
                                    java.nio.charset.Charset charset)
        Update the digest input with bytes from input in charset encoding.
        Parameters:
        input - the input String.
        charset - the encoding Charset.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(boolean input)
        Update the digest input with input.

        If true, a byte equal to 1, otherwise 0.

        Parameters:
        input - the input boolean.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(byte input)
        Update the digest input with input.
        Parameters:
        input - the inpute byte.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(short input)
        Update the digest input with the bytes from the big-endian representation of input.
        Parameters:
        input - the input short.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(int input)
        Update the digest input with the bytes from the big-endian representation of input.
        Parameters:
        input - the input int.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(long input)
        Update the digest input with the bytes from the big-endian representation of input.
        Parameters:
        input - the input long.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(float input)
        Update the digest input with the bytes from the big-endian representation of input's raw int bits.
        Parameters:
        input - the input float.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(double input)
        Update the digest input with the bytes from the big-endian representation of input's raw long bits.
        Parameters:
        input - the input double.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(byte[] input)
        Update the digest input with the bytes from the big-endian representation of each element of input.
        Parameters:
        input - the input array.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(short[] input)
        Update the digest input with the bytes from the big-endian representation of each element of input.
        Parameters:
        input - the input array.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(int[] input)
        Update the digest input with the bytes from the big-endian representation of each element of input.
        Parameters:
        input - the input array.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(long[] input)
        Update the digest input with the bytes from the big-endian representation of each element of input.
        Parameters:
        input - the input array.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(float[] input)
        Update the digest input with the bytes from the big-endian representation of each element of input.
        Parameters:
        input - the input array.
        Returns:
        this DigestBuilder.
      • update

        public DigestBuilder update​(double[] input)
        Update the digest input with the bytes from the big-endian representation of each element of input.
        Parameters:
        input - the input array.
        Returns:
        this DigestBuilder.
      • build

        public byte[] build()
        Compute and return the digest.

        The underlying MessageDigest is reset and this builder can be re-used.

        Returns:
        the computed digest.
      • buildHexString

        public java.lang.String buildHexString()
        Compute and return the digest as a lower-case hex-encoded String.

        The underlying MessageDigest is reset and this builder can be re-used.

        Returns:
        the computed digest as a lower-case hex-encoded String.