@@ -333,6 +333,30 @@ public static MessageDigest getSha512Digest() {
333333 return getDigest (MessageDigestAlgorithms .SHA_512 );
334334 }
335335
336+ /**
337+ * Returns an SHA-512/224 digest.
338+ *
339+ * @return An SHA-512/224 digest instance.
340+ * @throws IllegalArgumentException
341+ * when a {@link NoSuchAlgorithmException} is caught.
342+ * @see MessageDigestAlgorithms#SHA_512_224
343+ */
344+ public static MessageDigest getSha512_224Digest () {
345+ return getDigest (MessageDigestAlgorithms .SHA_512_224 );
346+ }
347+
348+ /**
349+ * Returns an SHA-512/256 digest.
350+ *
351+ * @return An SHA-512/256 digest instance.
352+ * @throws IllegalArgumentException
353+ * when a {@link NoSuchAlgorithmException} is caught.
354+ * @see MessageDigestAlgorithms#SHA_512_224
355+ */
356+ public static MessageDigest getSha512_256Digest () {
357+ return getDigest (MessageDigestAlgorithms .SHA_512_256 );
358+ }
359+
336360 /**
337361 * Returns an SHA-1 digest.
338362 *
@@ -1089,6 +1113,30 @@ public static byte[] sha512(final byte[] data) {
10891113 return getSha512Digest ().digest (data );
10901114 }
10911115
1116+ /**
1117+ * Calculates the SHA-512/224 digest and returns the value as a {@code byte[]}.
1118+ *
1119+ * @param data
1120+ * Data to digest
1121+ * @return SHA-512/224 digest
1122+ * @since 1.14
1123+ */
1124+ public static byte [] sha512_224 (final byte [] data ) {
1125+ return getSha512_224Digest ().digest (data );
1126+ }
1127+
1128+ /**
1129+ * Calculates the SHA-512/256 digest and returns the value as a {@code byte[]}.
1130+ *
1131+ * @param data
1132+ * Data to digest
1133+ * @return SHA-512/256 digest
1134+ * @since 1.14
1135+ */
1136+ public static byte [] sha512_256 (final byte [] data ) {
1137+ return getSha512_256Digest ().digest (data );
1138+ }
1139+
10921140 /**
10931141 * Calculates the SHA-512 digest and returns the value as a {@code byte[]}.
10941142 *
@@ -1103,6 +1151,34 @@ public static byte[] sha512(final InputStream data) throws IOException {
11031151 return digest (getSha512Digest (), data );
11041152 }
11051153
1154+ /**
1155+ * Calculates the SHA-512/224 digest and returns the value as a {@code byte[]}.
1156+ *
1157+ * @param data
1158+ * Data to digest
1159+ * @return SHA-512/224 digest
1160+ * @throws IOException
1161+ * On error reading from the stream
1162+ * @since 1.14
1163+ */
1164+ public static byte [] sha512_224 (final InputStream data ) throws IOException {
1165+ return digest (getSha512_224Digest (), data );
1166+ }
1167+
1168+ /**
1169+ * Calculates the SHA-512/256 digest and returns the value as a {@code byte[]}.
1170+ *
1171+ * @param data
1172+ * Data to digest
1173+ * @return SHA-512/256 digest
1174+ * @throws IOException
1175+ * On error reading from the stream
1176+ * @since 1.14
1177+ */
1178+ public static byte [] sha512_256 (final InputStream data ) throws IOException {
1179+ return digest (getSha512_256Digest (), data );
1180+ }
1181+
11061182 /**
11071183 * Calculates the SHA-512 digest and returns the value as a {@code byte[]}.
11081184 *
@@ -1115,6 +1191,30 @@ public static byte[] sha512(final String data) {
11151191 return sha512 (StringUtils .getBytesUtf8 (data ));
11161192 }
11171193
1194+ /**
1195+ * Calculates the SHA-512/224 digest and returns the value as a {@code byte[]}.
1196+ *
1197+ * @param data
1198+ * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
1199+ * @return SHA-512/224 digest
1200+ * @since 1.14
1201+ */
1202+ public static byte [] sha512_224 (final String data ) {
1203+ return sha512_224 (StringUtils .getBytesUtf8 (data ));
1204+ }
1205+
1206+ /**
1207+ * Calculates the SHA-512/256 digest and returns the value as a {@code byte[]}.
1208+ *
1209+ * @param data
1210+ * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
1211+ * @return SHA-512/224 digest
1212+ * @since 1.14
1213+ */
1214+ public static byte [] sha512_256 (final String data ) {
1215+ return sha512_256 (StringUtils .getBytesUtf8 (data ));
1216+ }
1217+
11181218 /**
11191219 * Calculates the SHA-512 digest and returns the value as a hex string.
11201220 *
@@ -1127,6 +1227,58 @@ public static String sha512Hex(final byte[] data) {
11271227 return Hex .encodeHexString (sha512 (data ));
11281228 }
11291229
1230+ /**
1231+ * Calculates the SHA-512/224 digest and returns the value as a hex string.
1232+ *
1233+ * @param data
1234+ * Data to digest
1235+ * @return SHA-512/224 digest as a hex string
1236+ * @since 1.14
1237+ */
1238+ public static String sha512_224Hex (final byte [] data ) {
1239+ return Hex .encodeHexString (sha512_224 (data ));
1240+ }
1241+
1242+ /**
1243+ * Calculates the SHA-512/256 digest and returns the value as a hex string.
1244+ *
1245+ * @param data
1246+ * Data to digest
1247+ * @return SHA-512/256 digest as a hex string
1248+ * @since 1.14
1249+ */
1250+ public static String sha512_256Hex (final byte [] data ) {
1251+ return Hex .encodeHexString (sha512_256 (data ));
1252+ }
1253+
1254+ /**
1255+ * Calculates the SHA-512/224 digest and returns the value as a hex string.
1256+ *
1257+ * @param data
1258+ * Data to digest
1259+ * @return SHA-512/224 digest as a hex string
1260+ * @throws IOException
1261+ * On error reading from the stream
1262+ * @since 1.14
1263+ */
1264+ public static String sha512_224Hex (final InputStream data ) throws IOException {
1265+ return Hex .encodeHexString (sha512_224 (data ));
1266+ }
1267+
1268+ /**
1269+ * Calculates the SHA-512/256 digest and returns the value as a hex string.
1270+ *
1271+ * @param data
1272+ * Data to digest
1273+ * @return SHA-512/256 digest as a hex string
1274+ * @throws IOException
1275+ * On error reading from the stream
1276+ * @since 1.14
1277+ */
1278+ public static String sha512_256Hex (final InputStream data ) throws IOException {
1279+ return Hex .encodeHexString (sha512_256 (data ));
1280+ }
1281+
11301282 /**
11311283 * Calculates the SHA-512 digest and returns the value as a hex string.
11321284 *
@@ -1153,6 +1305,30 @@ public static String sha512Hex(final String data) {
11531305 return Hex .encodeHexString (sha512 (data ));
11541306 }
11551307
1308+ /**
1309+ * Calculates the SHA-512/224 digest and returns the value as a hex string.
1310+ *
1311+ * @param data
1312+ * Data to digest
1313+ * @return SHA-512/224 digest as a hex string
1314+ * @since 1.14
1315+ */
1316+ public static String sha512_224Hex (final String data ) {
1317+ return Hex .encodeHexString (sha512_224 (data ));
1318+ }
1319+
1320+ /**
1321+ * Calculates the SHA-512/256 digest and returns the value as a hex string.
1322+ *
1323+ * @param data
1324+ * Data to digest
1325+ * @return SHA-512/256 digest as a hex string
1326+ * @since 1.14
1327+ */
1328+ public static String sha512_256Hex (final String data ) {
1329+ return Hex .encodeHexString (sha512_256 (data ));
1330+ }
1331+
11561332 /**
11571333 * Calculates the SHA-1 digest and returns the value as a hex string.
11581334 *
0 commit comments