Package com.peterphi.std.crypto.digest
Class DigestHelper
java.lang.Object
com.peterphi.std.crypto.digest.DigestHelper
Where possible implementations should use DigestUtils from commons-codec
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longstatic longcrc32(InputStream is) static Stringstatic byte[]digest(InputStream is, String algorithm) static Stringdigest(InputStream is, String algorithm, int encoding) static Stringstatic Stringstatic byte[]sha1(byte[] plaintext) static Stringstatic Stringstatic Stringsha1(InputStream is, int encoding) static Stringstatic Stringstatic byte[]sha1hmac(byte[] key, byte[] text) static StringPerforms HMAC-SHA1 on the UTF-8 byte representation of stringsstatic StringPerforms HMAC-SHA1 on the UTF-8 byte representation of strings, returning the hexidecimal hash as a result
-
Field Details
-
ENCODE_BASE64
public static final int ENCODE_BASE64- See Also:
-
ENCODE_HEX
public static final int ENCODE_HEX- See Also:
-
SHA1
- See Also:
-
MD5
- See Also:
-
-
Constructor Details
-
DigestHelper
public DigestHelper()
-
-
Method Details
-
sha1hmac
Performs HMAC-SHA1 on the UTF-8 byte representation of strings- Parameters:
key-plaintext-- Returns:
-
sha1hmac
Performs HMAC-SHA1 on the UTF-8 byte representation of strings, returning the hexidecimal hash as a result- Parameters:
key-plaintext-- Returns:
-
sha1hmac
- Parameters:
key-text-- Returns:
- Throws:
IllegalArgumentException
-
sha1
- Throws:
NoSuchAlgorithmException
-
sha1
- Throws:
IOExceptionNoSuchAlgorithmException
-
sha1
public static String sha1(String plaintext, int encoding) throws IOException, NoSuchAlgorithmException - Throws:
IOExceptionNoSuchAlgorithmException
-
sha1
public static String sha1(File testFile) throws FileNotFoundException, IOException, NoSuchAlgorithmException -
sha1
public static String sha1(File testFile, int encoding) throws FileNotFoundException, IOException, NoSuchAlgorithmException -
sha1
public static String sha1(InputStream is, int encoding) throws FileNotFoundException, IOException, NoSuchAlgorithmException -
digest
public static String digest(File testFile, String algorithm, int encoding) throws IOException, NoSuchAlgorithmException - Throws:
IOExceptionNoSuchAlgorithmException
-
digest
public static byte[] digest(InputStream is, String algorithm) throws IOException, NoSuchAlgorithmException - Throws:
IOExceptionNoSuchAlgorithmException
-
digest
public static String digest(InputStream is, String algorithm, int encoding) throws IOException, NoSuchAlgorithmException - Throws:
IOExceptionNoSuchAlgorithmException
-
crc32
- Throws:
FileNotFoundExceptionIOException
-
crc32
- Throws:
IOException
-
md5
public static String md5(File testFile) throws FileNotFoundException, IOException, NoSuchAlgorithmException -
md5
public static String md5(File testFile, int encoding) throws FileNotFoundException, IOException, NoSuchAlgorithmException
-