commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1637908 - /commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
Date Mon, 10 Nov 2014 16:13:23 GMT
Author: ggregory
Date: Mon Nov 10 16:13:23 2014
New Revision: 1637908

URL: http://svn.apache.org/r1637908
Log:
Sort new methods from previous commit.

Modified:
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/DigestUtils.java

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/DigestUtils.java?rev=1637908&r1=1637907&r2=1637908&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/digest/DigestUtils.java
Mon Nov 10 16:13:23 2014
@@ -34,6 +34,8 @@ import org.apache.commons.codec.binary.S
  */
 public class DigestUtils {
 
+    private static final int STREAM_BUFFER_LENGTH = 1024;
+
     /**
      * Read through an ByteBuffer and returns the digest for the data
      *
@@ -206,6 +208,18 @@ public class DigestUtils {
      * @param data
      *            Data to digest
      * @return MD2 digest
+     * @since 1.11
+     */
+    public static byte[] md2(final ByteBuffer data) {
+        return digest(getMd2Digest(), data);
+    }
+
+    /**
+     * Calculates the MD2 digest and returns the value as a 16 element <code>byte[]</code>.
+     *
+     * @param data
+     *            Data to digest
+     * @return MD2 digest
      * @throws IOException
      *             On error reading from the stream
      * @since 1.7
@@ -288,66 +302,6 @@ public class DigestUtils {
     }
 
     /**
-     * Calculates the MD2 digest and returns the value as a 16 element <code>byte[]</code>.
-     *
-     * @param data
-     *            Data to digest
-     * @return MD2 digest
-     * @since 1.11
-     */
-    public static byte[] md2(final ByteBuffer data) {
-        return digest(getMd2Digest(), data);
-    }
-
-    /**
-     * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>.
-     *
-     * @param data
-     *            Data to digest
-     * @return SHA-1 digest
-     * @since 1.11
-     */
-    public static byte[] sha1(final ByteBuffer data) {
-        return digest(getSha1Digest(), data);
-    }
-
-    /**
-     * Calculates the SHA-256 digest and returns the value as a <code>byte[]</code>.
-     *
-     * @param data
-     *            Data to digest
-     * @return SHA-256 digest
-     * @since 1.11
-     */
-    public static byte[] sha256(final ByteBuffer data) {
-        return digest(getSha256Digest(), data);
-    }
-
-    /**
-     * Calculates the SHA-384 digest and returns the value as a <code>byte[]</code>.
-     *
-     * @param data
-     *            Data to digest
-     * @return SHA-384 digest
-     * @since 1.11
-     */
-    public static byte[] sha384(final ByteBuffer data) {
-        return digest(getSha384Digest(), data);
-    }
-
-    /**
-     * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>.
-     *
-     * @param data
-     *            Data to digest
-     * @return SHA-512 digest
-     * @since 1.11
-     */
-    public static byte[] sha512(final ByteBuffer data) {
-        return digest(getSha512Digest(), data);
-    }
-
-    /**
      * Calculates the MD5 digest and returns the value as a 16 element <code>byte[]</code>.
      *
      * @param data
@@ -407,19 +361,19 @@ public class DigestUtils {
         return Hex.encodeHexString(md5(data));
     }
 
-/**
-     * Calculates the MD5 digest and returns the value as a 32 character hex string.
-     *
-     * @param data
-     *            Data to digest
-     * @return MD5 digest as a hex string
-     * @throws IOException
-     *             On error reading from the stream
-     * @since 1.4
-     */
-    public static String md5Hex(final InputStream data) throws IOException {
-        return Hex.encodeHexString(md5(data));
-    }
+    /**
+         * Calculates the MD5 digest and returns the value as a 32 character hex string.
+         *
+         * @param data
+         *            Data to digest
+         * @return MD5 digest as a hex string
+         * @throws IOException
+         *             On error reading from the stream
+         * @since 1.4
+         */
+        public static String md5Hex(final InputStream data) throws IOException {
+            return Hex.encodeHexString(md5(data));
+        }
 
     /**
      * Calculates the MD5 digest and returns the value as a 32 character hex string.
@@ -445,19 +399,32 @@ public class DigestUtils {
         return sha1(data);
     }
 
+/**
+ * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>.
+ *
+ * @param data
+ *            Data to digest
+ * @return SHA-1 digest
+ * @throws IOException
+ *             On error reading from the stream
+ * @since 1.4
+ * @deprecated Use {@link #sha1(InputStream)}
+ */
+@Deprecated
+public static byte[] sha(final InputStream data) throws IOException {
+    return sha1(data);
+}
+
     /**
      * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>.
      *
      * @param data
      *            Data to digest
      * @return SHA-1 digest
-     * @throws IOException
-     *             On error reading from the stream
-     * @since 1.4
-     * @deprecated Use {@link #sha1(InputStream)}
+     * @deprecated Use {@link #sha1(String)}
      */
     @Deprecated
-    public static byte[] sha(final InputStream data) throws IOException {
+    public static byte[] sha(final String data) {
         return sha1(data);
     }
 
@@ -467,11 +434,10 @@ public class DigestUtils {
      * @param data
      *            Data to digest
      * @return SHA-1 digest
-     * @deprecated Use {@link #sha1(String)}
+     * @since 1.7
      */
-    @Deprecated
-    public static byte[] sha(final String data) {
-        return sha1(data);
+    public static byte[] sha1(final byte[] data) {
+        return getSha1Digest().digest(data);
     }
 
     /**
@@ -480,10 +446,10 @@ public class DigestUtils {
      * @param data
      *            Data to digest
      * @return SHA-1 digest
-     * @since 1.7
+     * @since 1.11
      */
-    public static byte[] sha1(final byte[] data) {
-        return getSha1Digest().digest(data);
+    public static byte[] sha1(final ByteBuffer data) {
+        return digest(getSha1Digest(), data);
     }
 
     /**
@@ -578,6 +544,18 @@ public class DigestUtils {
 
     /**
      * Calculates the SHA-256 digest and returns the value as a <code>byte[]</code>.
+     *
+     * @param data
+     *            Data to digest
+     * @return SHA-256 digest
+     * @since 1.11
+     */
+    public static byte[] sha256(final ByteBuffer data) {
+        return digest(getSha256Digest(), data);
+    }
+
+    /**
+     * Calculates the SHA-256 digest and returns the value as a <code>byte[]</code>.
      * <p>
      * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0.
      * </p>
@@ -684,6 +662,18 @@ public class DigestUtils {
 
     /**
      * Calculates the SHA-384 digest and returns the value as a <code>byte[]</code>.
+     *
+     * @param data
+     *            Data to digest
+     * @return SHA-384 digest
+     * @since 1.11
+     */
+    public static byte[] sha384(final ByteBuffer data) {
+        return digest(getSha384Digest(), data);
+    }
+
+    /**
+     * Calculates the SHA-384 digest and returns the value as a <code>byte[]</code>.
      * <p>
      * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0.
      * </p>
@@ -790,6 +780,18 @@ public class DigestUtils {
 
     /**
      * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>.
+     *
+     * @param data
+     *            Data to digest
+     * @return SHA-512 digest
+     * @since 1.11
+     */
+    public static byte[] sha512(final ByteBuffer data) {
+        return digest(getSha512Digest(), data);
+    }
+
+    /**
+     * Calculates the SHA-512 digest and returns the value as a <code>byte[]</code>.
      * <p>
      * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0.
      * </p>
@@ -990,6 +992,4 @@ public class DigestUtils {
         messageDigest.update(StringUtils.getBytesUtf8(valueToDigest));
         return messageDigest;
     }
-
-    private static final int STREAM_BUFFER_LENGTH = 1024;
 }



Mime
View raw message