Class CryptoHashUtil
- java.lang.Object
-
- com.github.toolarium.security.util.CryptoHashUtil
-
public final class CryptoHashUtil extends java.lang.ObjectThis util class provides a fassade to the cryptographic hash functions of the java API.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]createHash(java.lang.String algorithm, byte[] in)Creates an message digest of the given algorithm for the given input.byte[]createHash(java.lang.String provider, java.lang.String algorithm, byte[] in)Creates an message digest of the given algorithm for the given inputbyte[]createHashWithKey(java.lang.String provider, byte[] inputKey, byte[] in)Creates an message digest of the given algorithm for the given inputstatic CryptoHashUtilgetInstance()Get the instancebyte[]md5(byte[] in)Creates an MD5 message digest for the given input.byte[]sha1(byte[] in)Creates an SHA1 message digest for the given input.byte[]sha256(byte[] in)Creates an SHA-256 message digest for the given input.byte[]sha512(byte[] in)Creates an SHA-512 message digest for the given input.
-
-
-
Method Detail
-
getInstance
public static CryptoHashUtil getInstance()
Get the instance- Returns:
- the instance
-
md5
public byte[] md5(byte[] in) throws java.security.GeneralSecurityExceptionCreates an MD5 message digest for the given input.- Parameters:
in- the input- Returns:
- the md5 message digest for the input
- Throws:
java.security.GeneralSecurityException- in case of error
-
sha1
public byte[] sha1(byte[] in) throws java.security.GeneralSecurityExceptionCreates an SHA1 message digest for the given input.- Parameters:
in- the input- Returns:
- the SHA1 message digest for the input
- Throws:
java.security.GeneralSecurityException- in case of error
-
sha256
public byte[] sha256(byte[] in) throws java.security.GeneralSecurityExceptionCreates an SHA-256 message digest for the given input. This should be your best choice to verify signatures and certificates.- Parameters:
in- the input- Returns:
- the SHA-256 message digest for the input
- Throws:
java.security.GeneralSecurityException- in case of error
-
sha512
public byte[] sha512(byte[] in) throws java.security.GeneralSecurityExceptionCreates an SHA-512 message digest for the given input.- Parameters:
in- the input- Returns:
- the SHA-256 message digest for the input
- Throws:
java.security.GeneralSecurityException- in case of error
-
createHash
public byte[] createHash(java.lang.String algorithm, byte[] in) throws java.security.GeneralSecurityExceptionCreates an message digest of the given algorithm for the given input.- Parameters:
algorithm- the name of the digest algorithm to usein- the input- Returns:
- the message digest for the input
- Throws:
java.security.GeneralSecurityException- in case of error
-
createHash
public byte[] createHash(java.lang.String provider, java.lang.String algorithm, byte[] in) throws java.security.GeneralSecurityExceptionCreates an message digest of the given algorithm for the given input- Parameters:
provider- the provider to usealgorithm- the name of the digest algorithm to usein- the input- Returns:
- the message digest for the input
- Throws:
java.security.GeneralSecurityException- in case of error
-
createHashWithKey
public byte[] createHashWithKey(java.lang.String provider, byte[] inputKey, byte[] in) throws java.security.GeneralSecurityExceptionCreates an message digest of the given algorithm for the given input- Parameters:
provider- the provider to useinputKey- the keyin- the input message- Returns:
- the message digest
- Throws:
java.security.GeneralSecurityException- in case of errorUnsupportedEncodingException- in case of error
-
-