Class AuthTools


  • public final class AuthTools
    extends Object
    This class is used to get different types of digests.
    Author:
    Matthias Herlitzius
    • Method Detail

      • base64ToByte

        public static byte[] base64ToByte​(String data)
                                   throws IOException
        From a base 64 representation, returns the corresponding byte[]
        Parameters:
        data - The base 64 data to be converted to byte[].
        Returns:
        The base 64 data converted to byte[].
        Throws:
        IOException
      • byteToBase64

        public static String byteToBase64​(byte[] data)
        From a byte[] returns a base 64 representation.
        Parameters:
        data - The byte[] to be converted to base 64.
        Returns:
        The byte[] converted to base 64.
      • getRandomSalt

        public static String getRandomSalt​(int length)
        Returns a random salt with a given length.
        Parameters:
        length - The length of the salt in byte.
        Returns:
        A random salt, represented as base 64. The value of the length parameter is only relevant for the length of byte[], which is internally used to generate the salt. The length of the returned base 64 representation of the salt may be different than the value of the length parameter.
      • getMd5Digest

        public static String getMd5Digest​(String input)
        Returns a MD5 digest. Although this convenience method is provided, it is recommended to use the stronger getSha512Digest(String) method or at least the getSha1Digest(String) method.
        Parameters:
        input - the input string
        Returns:
        the MD5 hash of the input string
      • getSha1Digest

        public static String getSha1Digest​(String input)
        Returns a SHA-1 digest. It is recommended to use the stronger getSha512Digest(String) method.
        Parameters:
        input - the input string
        Returns:
        the SHA-1 hash of the input string
      • getSha512Digest

        public static String getSha512Digest​(String input)
        Returns a SHA-512 digest.
        Parameters:
        input - the input string
        Returns:
        the SHA-512 hash of the input string