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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
static long
crc32
(InputStream is) static String
static byte[]
digest
(InputStream is, String algorithm) static String
digest
(InputStream is, String algorithm, int encoding) static String
static String
static byte[]
sha1
(byte[] plaintext) static String
static String
static String
sha1
(InputStream is, int encoding) static String
static String
static byte[]
sha1hmac
(byte[] key, byte[] text) static String
Performs HMAC-SHA1 on the UTF-8 byte representation of stringsstatic String
Performs 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:
IOException
NoSuchAlgorithmException
-
sha1
public static String sha1(String plaintext, int encoding) throws IOException, NoSuchAlgorithmException - Throws:
IOException
NoSuchAlgorithmException
-
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:
IOException
NoSuchAlgorithmException
-
digest
public static byte[] digest(InputStream is, String algorithm) throws IOException, NoSuchAlgorithmException - Throws:
IOException
NoSuchAlgorithmException
-
digest
public static String digest(InputStream is, String algorithm, int encoding) throws IOException, NoSuchAlgorithmException - Throws:
IOException
NoSuchAlgorithmException
-
crc32
- Throws:
FileNotFoundException
IOException
-
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
-