@@ -129,6 +129,22 @@ public static MessageDigest getSha1Digest() {
129129 return getDigest (MessageDigestAlgorithms .SHA_1 );
130130 }
131131
132+ /**
133+ * Returns an SHA-224 digest.
134+ * <p>
135+ * Java 8 only.
136+ * </p>
137+ *
138+ * @return An SHA-224 digest instance.
139+ * @throws IllegalArgumentException
140+ * when a {@link NoSuchAlgorithmException} is caught on Java 7 and older, SHA-224 is a built-in
141+ * algorithm on Java 8
142+ * @see MessageDigestAlgorithms#SHA_224
143+ */
144+ public static MessageDigest getSha224Digest () {
145+ return getDigest (MessageDigestAlgorithms .SHA_224 );
146+ }
147+
132148 /**
133149 * Returns an SHA-256 digest.
134150 * <p>
@@ -527,6 +543,135 @@ public static String sha1Hex(final String data) {
527543 return Hex .encodeHexString (sha1 (data ));
528544 }
529545
546+ /**
547+ * Calculates the SHA-224 digest and returns the value as a <code>byte[]</code>.
548+ * <p>
549+ * Throws a {@link IllegalArgumentException} on JRE versions prior to 1.4.0.
550+ * </p>
551+ *
552+ * @param data
553+ * Data to digest
554+ * @return SHA-224 digest
555+ * @throws IllegalArgumentException thrown on JRE versions prior to 1.8.0.
556+ * @since 1.11
557+ */
558+ public static byte [] sha224 (final byte [] data ) {
559+ return getSha224Digest ().digest (data );
560+ }
561+
562+ /**
563+ * Calculates the SHA-224 digest and returns the value as a <code>byte[]</code>.
564+ *
565+ * @param data
566+ * Data to digest
567+ * @return SHA-224 digest
568+ * @throws IllegalArgumentException thrown on JRE versions prior to 1.8.0.
569+ * @since 1.11
570+ */
571+ public static byte [] sha224 (final ByteBuffer data ) {
572+ return digest (getSha224Digest (), data );
573+ }
574+
575+ /**
576+ * Calculates the SHA-224 digest and returns the value as a <code>byte[]</code>.
577+ * <p>
578+ * Throws a {@link IllegalArgumentException} on JRE versions prior to 1.4.0.
579+ * </p>
580+ *
581+ * @param data
582+ * Data to digest
583+ * @return SHA-224 digest
584+ * @throws IOException
585+ * On error reading from the stream
586+ * @throws IllegalArgumentException thrown on JRE versions prior to 1.8.0.
587+ * @since 1.11
588+ */
589+ public static byte [] sha224 (final InputStream data ) throws IOException {
590+ return digest (getSha224Digest (), data );
591+ }
592+
593+ /**
594+ * Calculates the SHA-224 digest and returns the value as a <code>byte[]</code>.
595+ * <p>
596+ * Throws a {@link IllegalArgumentException} on JRE versions prior to 1.4.0.
597+ * </p>
598+ *
599+ * @param data
600+ * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)}
601+ * @return SHA-224 digest
602+ * @throws IllegalArgumentException thrown on JRE versions prior to 1.8.0.
603+ * @since 1.11
604+ */
605+ public static byte [] sha224 (final String data ) {
606+ return sha224 (StringUtils .getBytesUtf8 (data ));
607+ }
608+
609+ /**
610+ * Calculates the SHA-224 digest and returns the value as a hex string.
611+ * <p>
612+ * Throws a {@link IllegalArgumentException} on JRE versions prior to 1.4.0.
613+ * </p>
614+ *
615+ * @param data
616+ * Data to digest
617+ * @return SHA-224 digest as a hex string
618+ * @throws IllegalArgumentException thrown on JRE versions prior to 1.8.0.
619+ * @since 1.11
620+ */
621+ public static String sha224Hex (final byte [] data ) {
622+ return Hex .encodeHexString (sha224 (data ));
623+ }
624+
625+ /**
626+ * Calculates the SHA-224 digest and returns the value as a hex string.
627+ * <p>
628+ * Throws a {@link IllegalArgumentException} on JRE versions prior to 1.4.0.
629+ * </p>
630+ *
631+ * @param data
632+ * Data to digest
633+ * @return SHA-224 digest as a hex string
634+ * @throws IllegalArgumentException thrown on JRE versions prior to 1.8.0.
635+ * @since 1.11
636+ */
637+ public static String sha224Hex (final ByteBuffer data ) {
638+ return Hex .encodeHexString (sha224 (data ));
639+ }
640+
641+ /**
642+ * Calculates the SHA-224 digest and returns the value as a hex string.
643+ * <p>
644+ * Throws a {@link IllegalArgumentException} on JRE versions prior to 1.4.0.
645+ * </p>
646+ *
647+ * @param data
648+ * Data to digest
649+ * @return SHA-224 digest as a hex string
650+ * @throws IOException
651+ * On error reading from the stream
652+ * @throws IllegalArgumentException thrown on JRE versions prior to 1.8.0.
653+ * @since 1.11
654+ */
655+ public static String sha224Hex (final InputStream data ) throws IOException {
656+ return Hex .encodeHexString (sha224 (data ));
657+ }
658+
659+ /**
660+ * Calculates the SHA-224 digest and returns the value as a hex string.
661+ * <p>
662+ * Throws a {@link IllegalArgumentException} on JRE versions prior to 1.4.0.
663+ * </p>
664+ *
665+ * @param data
666+ * Data to digest
667+ * @return SHA-224 digest as a hex string
668+ * @throws IllegalArgumentException thrown on JRE versions prior to 1.8.0.
669+ * @since 1.11
670+ */
671+ public static String sha224Hex (final String data ) {
672+ return Hex .encodeHexString (sha224 (data ));
673+ }
674+
530675 /**
531676 * Calculates the SHA-256 digest and returns the value as a <code>byte[]</code>.
532677 * <p>
0 commit comments