File tree Expand file tree Collapse file tree
src/main/java/org/apache/commons/codec/digest Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,6 +58,38 @@ public final class HmacUtils {
5858
5959 private static final int STREAM_BUFFER_LENGTH = 1024 ;
6060
61+ /**
62+ * Returns whether this algorithm is available
63+ *
64+ *@param name the name to check
65+ * @return whether this algorithm is available
66+ * @since 1.11
67+ */
68+ public static boolean isAvailable (String name ) {
69+ try {
70+ Mac .getInstance (name );
71+ return true ;
72+ } catch (NoSuchAlgorithmException e ) {
73+ return false ;
74+ }
75+ }
76+
77+ /**
78+ * Returns whether this algorithm is available
79+ *
80+ *@param name the name to check
81+ * @return whether this algorithm is available
82+ * @since 1.11
83+ */
84+ public static boolean isAvailable (HmacAlgorithms name ) {
85+ try {
86+ Mac .getInstance (name .getName ());
87+ return true ;
88+ } catch (NoSuchAlgorithmException e ) {
89+ return false ;
90+ }
91+ }
92+
6193 /**
6294 * Returns an initialized <code>Mac</code> for the HmacMD5 algorithm.
6395 * <p>
You can’t perform that action at this time.
0 commit comments