You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/12/27 14:40:24 UTC
[commons-codec] 02/04: Sort methods.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git
commit be0c8dad01c2c2cc65cf13c0d712e48512133c81
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Dec 27 09:33:51 2019 -0500
Sort methods.
---
.../apache/commons/codec/digest/DigestUtils.java | 196 ++++++++---------
.../commons/codec/digest/DigestUtilsTest.java | 232 ++++++++++-----------
2 files changed, 214 insertions(+), 214 deletions(-)
diff --git a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
index 17175e3..985171f 100644
--- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
+++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
@@ -321,19 +321,6 @@ public class DigestUtils {
}
/**
- * Returns an SHA-512 digest.
- *
- * @return An SHA-512 digest instance.
- * @throws IllegalArgumentException
- * when a {@link NoSuchAlgorithmException} is caught, which should never happen
- * because SHA-512 is a built-in algorithm
- * @see MessageDigestAlgorithms#SHA_512
- */
- public static MessageDigest getSha512Digest() {
- return getDigest(MessageDigestAlgorithms.SHA_512);
- }
-
- /**
* Returns an SHA-512/224 digest.
*
* @return An SHA-512/224 digest instance.
@@ -358,6 +345,19 @@ public class DigestUtils {
}
/**
+ * Returns an SHA-512 digest.
+ *
+ * @return An SHA-512 digest instance.
+ * @throws IllegalArgumentException
+ * when a {@link NoSuchAlgorithmException} is caught, which should never happen
+ * because SHA-512 is a built-in algorithm
+ * @see MessageDigestAlgorithms#SHA_512
+ */
+ public static MessageDigest getSha512Digest() {
+ return getDigest(MessageDigestAlgorithms.SHA_512);
+ }
+
+ /**
* Returns an SHA-1 digest.
*
* @return An SHA-1 digest instance.
@@ -1114,41 +1114,41 @@ public class DigestUtils {
}
/**
- * Calculates the SHA-512/224 digest and returns the value as a {@code byte[]}.
+ * Calculates the SHA-512 digest and returns the value as a {@code byte[]}.
*
* @param data
* Data to digest
- * @return SHA-512/224 digest
- * @since 1.14
+ * @return SHA-512 digest
+ * @throws IOException
+ * On error reading from the stream
+ * @since 1.4
*/
- public static byte[] sha512_224(final byte[] data) {
- return getSha512_224Digest().digest(data);
+ public static byte[] sha512(final InputStream data) throws IOException {
+ return digest(getSha512Digest(), data);
}
/**
- * Calculates the SHA-512/256 digest and returns the value as a {@code byte[]}.
+ * Calculates the SHA-512 digest and returns the value as a {@code byte[]}.
*
* @param data
- * Data to digest
- * @return SHA-512/256 digest
- * @since 1.14
+ * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
+ * @return SHA-512 digest
+ * @since 1.4
*/
- public static byte[] sha512_256(final byte[] data) {
- return getSha512_256Digest().digest(data);
+ public static byte[] sha512(final String data) {
+ return sha512(StringUtils.getBytesUtf8(data));
}
/**
- * Calculates the SHA-512 digest and returns the value as a {@code byte[]}.
+ * Calculates the SHA-512/224 digest and returns the value as a {@code byte[]}.
*
* @param data
* Data to digest
- * @return SHA-512 digest
- * @throws IOException
- * On error reading from the stream
- * @since 1.4
+ * @return SHA-512/224 digest
+ * @since 1.14
*/
- public static byte[] sha512(final InputStream data) throws IOException {
- return digest(getSha512Digest(), data);
+ public static byte[] sha512_224(final byte[] data) {
+ return getSha512_224Digest().digest(data);
}
/**
@@ -1166,77 +1166,91 @@ public class DigestUtils {
}
/**
- * Calculates the SHA-512/256 digest and returns the value as a {@code byte[]}.
+ * Calculates the SHA-512/224 digest and returns the value as a {@code byte[]}.
+ *
+ * @param data
+ * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
+ * @return SHA-512/224 digest
+ * @since 1.14
+ */
+ public static byte[] sha512_224(final String data) {
+ return sha512_224(StringUtils.getBytesUtf8(data));
+ }
+
+ /**
+ * Calculates the SHA-512/224 digest and returns the value as a hex string.
*
* @param data
* Data to digest
- * @return SHA-512/256 digest
- * @throws IOException
- * On error reading from the stream
+ * @return SHA-512/224 digest as a hex string
* @since 1.14
*/
- public static byte[] sha512_256(final InputStream data) throws IOException {
- return digest(getSha512_256Digest(), data);
+ public static String sha512_224Hex(final byte[] data) {
+ return Hex.encodeHexString(sha512_224(data));
}
/**
- * Calculates the SHA-512 digest and returns the value as a {@code byte[]}.
+ * Calculates the SHA-512/224 digest and returns the value as a hex string.
*
* @param data
- * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
- * @return SHA-512 digest
- * @since 1.4
+ * Data to digest
+ * @return SHA-512/224 digest as a hex string
+ * @throws IOException
+ * On error reading from the stream
+ * @since 1.14
*/
- public static byte[] sha512(final String data) {
- return sha512(StringUtils.getBytesUtf8(data));
+ public static String sha512_224Hex(final InputStream data) throws IOException {
+ return Hex.encodeHexString(sha512_224(data));
}
/**
- * Calculates the SHA-512/224 digest and returns the value as a {@code byte[]}.
+ * Calculates the SHA-512/224 digest and returns the value as a hex string.
*
* @param data
- * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
- * @return SHA-512/224 digest
+ * Data to digest
+ * @return SHA-512/224 digest as a hex string
* @since 1.14
*/
- public static byte[] sha512_224(final String data) {
- return sha512_224(StringUtils.getBytesUtf8(data));
+ public static String sha512_224Hex(final String data) {
+ return Hex.encodeHexString(sha512_224(data));
}
/**
* Calculates the SHA-512/256 digest and returns the value as a {@code byte[]}.
*
* @param data
- * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
- * @return SHA-512/224 digest
+ * Data to digest
+ * @return SHA-512/256 digest
* @since 1.14
*/
- public static byte[] sha512_256(final String data) {
- return sha512_256(StringUtils.getBytesUtf8(data));
+ public static byte[] sha512_256(final byte[] data) {
+ return getSha512_256Digest().digest(data);
}
/**
- * Calculates the SHA-512 digest and returns the value as a hex string.
+ * Calculates the SHA-512/256 digest and returns the value as a {@code byte[]}.
*
* @param data
* Data to digest
- * @return SHA-512 digest as a hex string
- * @since 1.4
+ * @return SHA-512/256 digest
+ * @throws IOException
+ * On error reading from the stream
+ * @since 1.14
*/
- public static String sha512Hex(final byte[] data) {
- return Hex.encodeHexString(sha512(data));
+ public static byte[] sha512_256(final InputStream data) throws IOException {
+ return digest(getSha512_256Digest(), data);
}
/**
- * Calculates the SHA-512/224 digest and returns the value as a hex string.
+ * Calculates the SHA-512/256 digest and returns the value as a {@code byte[]}.
*
* @param data
- * Data to digest
- * @return SHA-512/224 digest as a hex string
+ * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
+ * @return SHA-512/224 digest
* @since 1.14
*/
- public static String sha512_224Hex(final byte[] data) {
- return Hex.encodeHexString(sha512_224(data));
+ public static byte[] sha512_256(final String data) {
+ return sha512_256(StringUtils.getBytesUtf8(data));
}
/**
@@ -1252,17 +1266,17 @@ public class DigestUtils {
}
/**
- * Calculates the SHA-512/224 digest and returns the value as a hex string.
+ * Calculates the SHA-512/256 digest and returns the value as a hex string.
*
* @param data
* Data to digest
- * @return SHA-512/224 digest as a hex string
+ * @return SHA-512/256 digest as a hex string
* @throws IOException
* On error reading from the stream
* @since 1.14
*/
- public static String sha512_224Hex(final InputStream data) throws IOException {
- return Hex.encodeHexString(sha512_224(data));
+ public static String sha512_256Hex(final InputStream data) throws IOException {
+ return Hex.encodeHexString(sha512_256(data));
}
/**
@@ -1271,11 +1285,9 @@ public class DigestUtils {
* @param data
* Data to digest
* @return SHA-512/256 digest as a hex string
- * @throws IOException
- * On error reading from the stream
* @since 1.14
*/
- public static String sha512_256Hex(final InputStream data) throws IOException {
+ public static String sha512_256Hex(final String data) {
return Hex.encodeHexString(sha512_256(data));
}
@@ -1285,11 +1297,9 @@ public class DigestUtils {
* @param data
* Data to digest
* @return SHA-512 digest as a hex string
- * @throws IOException
- * On error reading from the stream
* @since 1.4
*/
- public static String sha512Hex(final InputStream data) throws IOException {
+ public static String sha512Hex(final byte[] data) {
return Hex.encodeHexString(sha512(data));
}
@@ -1299,34 +1309,24 @@ public class DigestUtils {
* @param data
* Data to digest
* @return SHA-512 digest as a hex string
+ * @throws IOException
+ * On error reading from the stream
* @since 1.4
*/
- public static String sha512Hex(final String data) {
+ public static String sha512Hex(final InputStream data) throws IOException {
return Hex.encodeHexString(sha512(data));
}
/**
- * Calculates the SHA-512/224 digest and returns the value as a hex string.
- *
- * @param data
- * Data to digest
- * @return SHA-512/224 digest as a hex string
- * @since 1.14
- */
- public static String sha512_224Hex(final String data) {
- return Hex.encodeHexString(sha512_224(data));
- }
-
- /**
- * Calculates the SHA-512/256 digest and returns the value as a hex string.
+ * Calculates the SHA-512 digest and returns the value as a hex string.
*
* @param data
* Data to digest
- * @return SHA-512/256 digest as a hex string
- * @since 1.14
+ * @return SHA-512 digest as a hex string
+ * @since 1.4
*/
- public static String sha512_256Hex(final String data) {
- return Hex.encodeHexString(sha512_256(data));
+ public static String sha512Hex(final String data) {
+ return Hex.encodeHexString(sha512(data));
}
/**
@@ -1682,33 +1682,33 @@ public class DigestUtils {
}
/**
- * Reads through a File and returns the digest for the data
+ * Reads through an InputStream and returns the digest for the data
*
* @param data
* Data to digest
- * @param options
- * options How to open the file
* @return the digest as a hex string
* @throws IOException
* On error reading from the stream
* @since 1.11
*/
- public String digestAsHex(final Path data, final OpenOption... options) throws IOException {
- return Hex.encodeHexString(digest(data, options));
+ public String digestAsHex(final InputStream data) throws IOException {
+ return Hex.encodeHexString(digest(data));
}
/**
- * Reads through an InputStream and returns the digest for the data
+ * Reads through a File and returns the digest for the data
*
* @param data
* Data to digest
+ * @param options
+ * options How to open the file
* @return the digest as a hex string
* @throws IOException
* On error reading from the stream
* @since 1.11
*/
- public String digestAsHex(final InputStream data) throws IOException {
- return Hex.encodeHexString(digest(data));
+ public String digestAsHex(final Path data, final OpenOption... options) throws IOException {
+ return Hex.encodeHexString(digest(data, options));
}
/**
diff --git a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
index a5ea5f0..37d4c53 100644
--- a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java
@@ -112,12 +112,33 @@ public class DigestUtilsTest {
}
}
+ @Test
+ public void testDigestAs() throws IOException {
+ final String expected = "d41d8cd98f00b204e9800998ecf8427e";
+ final String pathname = "src/test/resources/empty.bin";
+ final String algo = MessageDigestAlgorithms.MD5;
+ assertEquals(expected, new DigestUtils(algo).digestAsHex(new File(pathname)));
+ try (final FileInputStream inputStream = new FileInputStream(pathname)) {
+ assertEquals(expected, new DigestUtils(algo).digestAsHex(inputStream));
+ }
+ final byte[] allBytes = Files.readAllBytes(Paths.get(pathname));
+ assertEquals(expected, new DigestUtils(algo).digestAsHex(allBytes));
+ assertEquals(expected, new DigestUtils(algo).digestAsHex(ByteBuffer.wrap(allBytes)));
+ }
+
@Test(expected=IllegalArgumentException.class)
public void testInternalNoSuchAlgorithmException() {
DigestUtils.getDigest("Bogus Bogus");
}
@Test
+ public void testIsAvailable() {
+ assertTrue(DigestUtils.isAvailable(MessageDigestAlgorithms.MD5));
+ assertFalse(DigestUtils.isAvailable("FOO"));
+ assertFalse(DigestUtils.isAvailable(null));
+ }
+
+ @Test
public void testMd2Hex() throws IOException {
// Examples from RFC 1319
assertEquals("8350e5a3e24c153df2275c9f80692773", DigestUtils.md2Hex(EMPTY_STRING));
@@ -169,7 +190,7 @@ public class DigestUtilsTest {
hash = DigestUtils.md2(getBytesUtf8(hashMe));
assertEquals(16, hash.length);
}
-
+
@Test
public void testMd5Hex() throws IOException {
// Examples from RFC 1321
@@ -195,13 +216,6 @@ public class DigestUtilsTest {
DigestUtils.md5Hex(new ByteArrayInputStream(testData)));
}
- @Test
- public void testIsAvailable() {
- assertTrue(DigestUtils.isAvailable(MessageDigestAlgorithms.MD5));
- assertFalse(DigestUtils.isAvailable("FOO"));
- assertFalse(DigestUtils.isAvailable(null));
- }
-
/**
* An MD5 hash converted to hex should always be 32 characters.
*/
@@ -299,17 +313,6 @@ public class DigestUtilsTest {
}
@Test
- public void testSha224_StringAsHex() {
- assumeJava8();
- assertEquals("d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
- new DigestUtils(MessageDigestAlgorithms.SHA_224).digestAsHex(EMPTY_STRING));
- assertEquals("730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525",
- new DigestUtils(MessageDigestAlgorithms.SHA_224).digestAsHex("The quick brown fox jumps over the lazy dog"));
-
- // Examples from FIPS 180-4?
- }
-
- @Test
public void testSha224_FileAsHex() throws IOException {
assumeJava8();
final String expected = "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f";
@@ -325,24 +328,21 @@ public class DigestUtilsTest {
}
@Test
- public void testDigestAs() throws IOException {
- final String expected = "d41d8cd98f00b204e9800998ecf8427e";
- final String pathname = "src/test/resources/empty.bin";
- final String algo = MessageDigestAlgorithms.MD5;
- assertEquals(expected, new DigestUtils(algo).digestAsHex(new File(pathname)));
- try (final FileInputStream inputStream = new FileInputStream(pathname)) {
- assertEquals(expected, new DigestUtils(algo).digestAsHex(inputStream));
- }
- final byte[] allBytes = Files.readAllBytes(Paths.get(pathname));
- assertEquals(expected, new DigestUtils(algo).digestAsHex(allBytes));
- assertEquals(expected, new DigestUtils(algo).digestAsHex(ByteBuffer.wrap(allBytes)));
+ public void testSha224_PathAsHex() throws IOException {
+ assumeJava8();
+ assertEquals("d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
+ new DigestUtils(MessageDigestAlgorithms.SHA_224).digestAsHex(Paths.get("src/test/resources/empty.bin")));
}
@Test
- public void testSha224_PathAsHex() throws IOException {
+ public void testSha224_StringAsHex() {
assumeJava8();
assertEquals("d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f",
- new DigestUtils(MessageDigestAlgorithms.SHA_224).digestAsHex(Paths.get("src/test/resources/empty.bin")));
+ new DigestUtils(MessageDigestAlgorithms.SHA_224).digestAsHex(EMPTY_STRING));
+ assertEquals("730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525",
+ new DigestUtils(MessageDigestAlgorithms.SHA_224).digestAsHex("The quick brown fox jumps over the lazy dog"));
+
+ // Examples from FIPS 180-4?
}
@Test
@@ -360,6 +360,84 @@ public class DigestUtilsTest {
}
@Test
+ public void testSha256HexInputStream() throws IOException {
+ assertEquals(DigestUtils.sha256Hex(testData),
+ DigestUtils.sha256Hex(new ByteArrayInputStream(testData)));
+ }
+
+ @Test
+ public void testSha3_224() {
+ assumeJava9();
+ // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
+ //
+ // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-224_Msg0.pdf
+ assertEquals(
+ "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7",
+ DigestUtils.sha3_224Hex(EMPTY_STRING));
+ }
+
+ @Test
+ public void testSha3_224HexInputStream() throws IOException {
+ assumeJava9();
+ assertEquals(DigestUtils.sha3_224Hex(testData),
+ DigestUtils.sha3_224Hex(new ByteArrayInputStream(testData)));
+ }
+
+ @Test
+ public void testSha3_256() {
+ assumeJava9();
+ // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
+ //
+ // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-256_Msg0.pdf
+ assertEquals(
+ "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a",
+ DigestUtils.sha3_256Hex(EMPTY_STRING));
+ }
+
+ @Test
+ public void testSha3_256HexInputStream() throws IOException {
+ assumeJava9();
+ assertEquals(DigestUtils.sha3_256Hex(testData),
+ DigestUtils.sha3_256Hex(new ByteArrayInputStream(testData)));
+ }
+
+ @Test
+ public void testSha3_384() {
+ assumeJava9();
+ // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
+ //
+ // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-384_Msg0.pdf
+ assertEquals(
+ "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004",
+ DigestUtils.sha3_384Hex(EMPTY_STRING));
+ }
+
+ @Test
+ public void testSha3_384HexInputStream() throws IOException {
+ assumeJava9();
+ assertEquals(DigestUtils.sha3_384Hex(testData),
+ DigestUtils.sha3_384Hex(new ByteArrayInputStream(testData)));
+ }
+
+ @Test
+ public void testSha3_512() {
+ assumeJava9();
+ // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
+ //
+ // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-512_Msg0.pdf
+ assertEquals(
+ "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26",
+ DigestUtils.sha3_512Hex(EMPTY_STRING));
+ }
+
+ @Test
+ public void testSha3_512HexInputStream() throws IOException {
+ assumeJava9();
+ assertEquals(DigestUtils.sha3_512Hex(testData),
+ DigestUtils.sha3_512Hex(new ByteArrayInputStream(testData)));
+ }
+
+ @Test
public void testSha384() throws IOException {
// Examples from FIPS 180-2
assertEquals("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed" +
@@ -377,6 +455,12 @@ public class DigestUtilsTest {
}
@Test
+ public void testSha384HexInputStream() throws IOException {
+ assertEquals(DigestUtils.sha384Hex(testData),
+ DigestUtils.sha384Hex(new ByteArrayInputStream(testData)));
+ }
+
+ @Test
public void testSha512() {
// Examples from FIPS 180-2
assertEquals("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" +
@@ -439,95 +523,11 @@ public class DigestUtilsTest {
}
@Test
- public void testSha3_224() {
- assumeJava9();
- // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
- //
- // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-224_Msg0.pdf
- assertEquals(
- "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7",
- DigestUtils.sha3_224Hex(EMPTY_STRING));
- }
-
- @Test
- public void testSha3_256() {
- assumeJava9();
- // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
- //
- // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-256_Msg0.pdf
- assertEquals(
- "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a",
- DigestUtils.sha3_256Hex(EMPTY_STRING));
- }
-
- @Test
- public void testSha3_384() {
- assumeJava9();
- // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
- //
- // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-384_Msg0.pdf
- assertEquals(
- "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004",
- DigestUtils.sha3_384Hex(EMPTY_STRING));
- }
-
- @Test
- public void testSha3_512() {
- assumeJava9();
- // Examples from https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
- //
- // https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/SHA3-512_Msg0.pdf
- assertEquals(
- "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26",
- DigestUtils.sha3_512Hex(EMPTY_STRING));
- }
-
- @Test
- public void testSha256HexInputStream() throws IOException {
- assertEquals(DigestUtils.sha256Hex(testData),
- DigestUtils.sha256Hex(new ByteArrayInputStream(testData)));
- }
-
- @Test
- public void testSha384HexInputStream() throws IOException {
- assertEquals(DigestUtils.sha384Hex(testData),
- DigestUtils.sha384Hex(new ByteArrayInputStream(testData)));
- }
-
- @Test
public void testSha512HexInputStream() throws IOException {
assertEquals(DigestUtils.sha512Hex(testData),
DigestUtils.sha512Hex(new ByteArrayInputStream(testData)));
}
- @Test
- public void testSha3_224HexInputStream() throws IOException {
- assumeJava9();
- assertEquals(DigestUtils.sha3_224Hex(testData),
- DigestUtils.sha3_224Hex(new ByteArrayInputStream(testData)));
- }
-
- @Test
- public void testSha3_256HexInputStream() throws IOException {
- assumeJava9();
- assertEquals(DigestUtils.sha3_256Hex(testData),
- DigestUtils.sha3_256Hex(new ByteArrayInputStream(testData)));
- }
-
- @Test
- public void testSha3_384HexInputStream() throws IOException {
- assumeJava9();
- assertEquals(DigestUtils.sha3_384Hex(testData),
- DigestUtils.sha3_384Hex(new ByteArrayInputStream(testData)));
- }
-
- @Test
- public void testSha3_512HexInputStream() throws IOException {
- assumeJava9();
- assertEquals(DigestUtils.sha3_512Hex(testData),
- DigestUtils.sha3_512Hex(new ByteArrayInputStream(testData)));
- }
-
@SuppressWarnings("deprecation") // deliberate tests of deprecated code
@Test
public void testShaHex() throws IOException {