Package org.appng.api.auth
Class AuthTools
- java.lang.Object
-
- org.appng.api.auth.AuthTools
-
public final class AuthTools extends Object
This class is used to get different types of digests.- Author:
- Matthias Herlitzius
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
base64ToByte(String data)
From a base 64 representation, returns the corresponding byte[]static String
byteToBase64(byte[] data)
From a byte[] returns a base 64 representation.static String
getMd5Digest(String input)
Returns a MD5 digest.static String
getRandomSalt(int length)
Returns a random salt with a given length.static String
getSha1Digest(String input)
Returns a SHA-1 digest.static String
getSha512Digest(String input)
Returns a SHA-512 digest.
-
-
-
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 strongergetSha512Digest(String)
method or at least thegetSha1Digest(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 strongergetSha512Digest(String)
method.- Parameters:
input
- the input string- Returns:
- the SHA-1 hash of the input string
-
-