diff --git a/src/main/java/org/apache/commons/codec/binary/Hex.java b/src/main/java/org/apache/commons/codec/binary/Hex.java index 2c501412ea..61e41ac0c4 100644 --- a/src/main/java/org/apache/commons/codec/binary/Hex.java +++ b/src/main/java/org/apache/commons/codec/binary/Hex.java @@ -135,7 +135,7 @@ public static byte[] decodeHex(final String data) throws DecoderException { * The returned array will be double the length of the passed array, as it takes two characters to represent any * given byte. * - * @param data a byte[] to convert to hex characters + * @param data a byte[] to convert to hexadecimal characters * @return A char[] containing lower-case hexadecimal characters */ public static char[] encodeHex(final byte[] data) { @@ -161,7 +161,7 @@ public static char[] encodeHex(final byte[] data, final boolean toLowerCase) { * The returned array will be double the length of the passed array, as it takes two characters to represent any * given byte. * - * @param data a byte[] to convert to hex characters + * @param data a byte[] to convert to hexadecimal characters * @param toDigits the output alphabet (must contain at least 16 chars) * @return A char[] containing the appropriate characters from the alphabet For best results, this should be either * upper- or lower-case hex. @@ -177,7 +177,7 @@ protected static char[] encodeHex(final byte[] data, final char[] toDigits) { /** * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. * - * @param data a byte[] to convert to hex characters + * @param data a byte[] to convert to hexadecimal characters * @param dataOffset the position in {@code data} to start encoding from * @param dataLen the number of bytes from {@code dataOffset} to encode * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase @@ -195,7 +195,7 @@ public static char[] encodeHex(final byte[] data, final int dataOffset, final in /** * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. * - * @param data a byte[] to convert to hex characters + * @param data a byte[] to convert to hexadecimal characters * @param dataOffset the position in {@code data} to start encoding from * @param dataLen the number of bytes from {@code dataOffset} to encode * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase @@ -211,7 +211,7 @@ public static void encodeHex(final byte[] data, final int dataOffset, final int /** * Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order. * - * @param data a byte[] to convert to hex characters + * @param data a byte[] to convert to hexadecimal characters * @param dataOffset the position in {@code data} to start encoding from * @param dataLen the number of bytes from {@code dataOffset} to encode * @param toDigits the output alphabet (must contain at least 16 chars) @@ -235,7 +235,7 @@ private static void encodeHex(final byte[] data, final int dataOffset, final int *

All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method * the value {@link ByteBuffer#remaining() remaining()} will be zero.

* - * @param data a byte buffer to convert to hex characters + * @param data a byte buffer to convert to hexadecimal characters * @return A char[] containing lower-case hexadecimal characters * @since 1.11 */ @@ -251,7 +251,7 @@ public static char[] encodeHex(final ByteBuffer data) { *

All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method * the value {@link ByteBuffer#remaining() remaining()} will be zero.

* - * @param data a byte buffer to convert to hex characters + * @param data a byte buffer to convert to hexadecimal characters * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase * @return A char[] containing hexadecimal characters in the selected case * @since 1.11 @@ -268,7 +268,7 @@ public static char[] encodeHex(final ByteBuffer data, final boolean toLowerCase) *

All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method * the value {@link ByteBuffer#remaining() remaining()} will be zero.

* - * @param byteBuffer a byte buffer to convert to hex characters + * @param byteBuffer a byte buffer to convert to hexadecimal characters * @param toDigits the output alphabet (must be at least 16 characters) * @return A char[] containing the appropriate characters from the alphabet For best results, this should be either * upper- or lower-case hex. @@ -282,7 +282,7 @@ protected static char[] encodeHex(final ByteBuffer byteBuffer, final char[] toDi * Converts an array of bytes into a String representing the hexadecimal values of each byte in order. The returned * String will be double the length of the passed array, as it takes two characters to represent any given byte. * - * @param data a byte[] to convert to hex characters + * @param data a byte[] to convert to hexadecimal characters * @return A String containing lower-case hexadecimal characters * @since 1.4 */ @@ -294,7 +294,7 @@ public static String encodeHexString(final byte[] data) { * Converts an array of bytes into a String representing the hexadecimal values of each byte in order. The returned * String will be double the length of the passed array, as it takes two characters to represent any given byte. * - * @param data a byte[] to convert to hex characters + * @param data a byte[] to convert to hexadecimal characters * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase * @return A String containing lower-case hexadecimal characters * @since 1.11 @@ -310,7 +310,7 @@ public static String encodeHexString(final byte[] data, final boolean toLowerCas *

All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method * the value {@link ByteBuffer#remaining() remaining()} will be zero.

* - * @param data a byte buffer to convert to hex characters + * @param data a byte buffer to convert to hexadecimal characters * @return A String containing lower-case hexadecimal characters * @since 1.11 */ @@ -325,7 +325,7 @@ public static String encodeHexString(final ByteBuffer data) { *

All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method * the value {@link ByteBuffer#remaining() remaining()} will be zero.

* - * @param data a byte buffer to convert to hex characters + * @param data a byte buffer to convert to hexadecimal characters * @param toLowerCase {@code true} converts to lowercase, {@code false} to uppercase * @return A String containing lower-case hexadecimal characters * @since 1.11 @@ -363,7 +363,7 @@ private static byte[] toByteArray(final ByteBuffer byteBuffer) { * @param ch A character to convert to an integer digit * @param index The index of the character in the source * @return An integer - * @throws DecoderException Thrown if ch is an illegal hex character + * @throws DecoderException Thrown if ch is an illegal hexadecimal character */ protected static int toDigit(final char ch, final int index) throws DecoderException { final int digit = Character.digit(ch, 16); @@ -474,7 +474,7 @@ public Object decode(final Object object) throws DecoderException { * {@link #getCharset()}. *

* - * @param array a byte[] to convert to hex characters + * @param array a byte[] to convert to hexadecimal characters * @return A byte[] containing the bytes of the lower-case hexadecimal characters * @since 1.7 No longer throws IllegalStateException if the charsetName is invalid. * @see #encodeHex(byte[]) @@ -495,7 +495,7 @@ public byte[] encode(final byte[] array) { *

All bytes identified by {@link ByteBuffer#remaining()} will be used; after this method * the value {@link ByteBuffer#remaining() remaining()} will be zero.

* - * @param array a byte buffer to convert to hex characters + * @param array a byte buffer to convert to hexadecimal characters * @return A byte[] containing the bytes of the lower-case hexadecimal characters * @see #encodeHex(byte[]) * @since 1.11 @@ -513,7 +513,7 @@ public byte[] encode(final ByteBuffer array) { * {@link #getCharset()}. *

* - * @param object a String, ByteBuffer, or byte[] to convert to hex characters + * @param object a String, ByteBuffer, or byte[] to convert to hexadecimal characters * @return A char[] containing lower-case hexadecimal characters * @throws EncoderException Thrown if the given object is not a String or byte[] * @see #encodeHex(byte[]) 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 c71bb21d2c..f5cc1dd481 100644 --- a/src/main/java/org/apache/commons/codec/digest/DigestUtils.java +++ b/src/main/java/org/apache/commons/codec/digest/DigestUtils.java @@ -45,14 +45,14 @@ * Note: the class has shorthand methods for all the algorithms present as standard in Java 6. This approach requires lots of methods for each algorithm, and * quickly becomes unwieldy. The following code works with all algorithms: *

- * + * *
  * import static org.apache.commons.codec.digest.MessageDigestAlgorithms.SHA_224;
  * ...
  * byte [] digest = new DigestUtils(SHA_224).digest(dataToDigest);
  * String hdigest = new DigestUtils(SHA_224).digestAsHex(new File("pom.xml"));
  * 
- * + * * @see MessageDigestAlgorithms */ public class DigestUtils { @@ -342,7 +342,7 @@ public static MessageDigest getShaDigest() { /** * Test whether the algorithm is supported. - * + * * @param messageDigestAlgorithm the algorithm name * @return {@code true} if the algorithm can be found * @since 1.11 @@ -386,10 +386,10 @@ public static byte[] md2(final String data) { } /** - * Calculates the MD2 digest and returns the value as a 32 character hex string. + * Calculates the MD2 digest and returns the value as a 32 character hexadecimal string. * * @param data Data to digest - * @return MD2 digest as a hex string + * @return MD2 digest as a hexadecimal string * @since 1.7 */ public static String md2Hex(final byte[] data) { @@ -397,10 +397,10 @@ public static String md2Hex(final byte[] data) { } /** - * Calculates the MD2 digest and returns the value as a 32 character hex string. + * Calculates the MD2 digest and returns the value as a 32 character hexadecimal string. * * @param data Data to digest - * @return MD2 digest as a hex string + * @return MD2 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.7 */ @@ -409,10 +409,10 @@ public static String md2Hex(final InputStream data) throws IOException { } /** - * Calculates the MD2 digest and returns the value as a 32 character hex string. + * Calculates the MD2 digest and returns the value as a 32 character hexadecimal string. * * @param data Data to digest - * @return MD2 digest as a hex string + * @return MD2 digest as a hexadecimal string * @since 1.7 */ public static String md2Hex(final String data) { @@ -452,20 +452,20 @@ public static byte[] md5(final String data) { } /** - * Calculates the MD5 digest and returns the value as a 32 character hex string. + * Calculates the MD5 digest and returns the value as a 32 character hexadecimal string. * * @param data Data to digest - * @return MD5 digest as a hex string + * @return MD5 digest as a hexadecimal string */ public static String md5Hex(final byte[] data) { return Hex.encodeHexString(md5(data)); } /** - * Calculates the MD5 digest and returns the value as a 32 character hex string. + * Calculates the MD5 digest and returns the value as a 32 character hexadecimal string. * * @param data Data to digest - * @return MD5 digest as a hex string + * @return MD5 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.4 */ @@ -474,10 +474,10 @@ public static String md5Hex(final InputStream data) throws IOException { } /** - * Calculates the MD5 digest and returns the value as a 32 character hex string. + * Calculates the MD5 digest and returns the value as a 32 character hexadecimal string. * * @param data Data to digest - * @return MD5 digest as a hex string + * @return MD5 digest as a hexadecimal string */ public static String md5Hex(final String data) { return Hex.encodeHexString(md5(data)); @@ -555,10 +555,10 @@ public static byte[] sha1(final String data) { } /** - * Calculates the SHA-1 digest and returns the value as a hex string. + * Calculates the SHA-1 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-1 digest as a hex string + * @return SHA-1 digest as a hexadecimal string * @since 1.7 */ public static String sha1Hex(final byte[] data) { @@ -566,10 +566,10 @@ public static String sha1Hex(final byte[] data) { } /** - * Calculates the SHA-1 digest and returns the value as a hex string. + * Calculates the SHA-1 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-1 digest as a hex string + * @return SHA-1 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.7 */ @@ -578,10 +578,10 @@ public static String sha1Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA-1 digest and returns the value as a hex string. + * Calculates the SHA-1 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-1 digest as a hex string + * @return SHA-1 digest as a hexadecimal string * @since 1.7 */ public static String sha1Hex(final String data) { @@ -623,10 +623,10 @@ public static byte[] sha256(final String data) { } /** - * Calculates the SHA-256 digest and returns the value as a hex string. + * Calculates the SHA-256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-256 digest as a hex string + * @return SHA-256 digest as a hexadecimal string * @since 1.4 */ public static String sha256Hex(final byte[] data) { @@ -634,10 +634,10 @@ public static String sha256Hex(final byte[] data) { } /** - * Calculates the SHA-256 digest and returns the value as a hex string. + * Calculates the SHA-256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-256 digest as a hex string + * @return SHA-256 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.4 */ @@ -646,10 +646,10 @@ public static String sha256Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA-256 digest and returns the value as a hex string. + * Calculates the SHA-256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-256 digest as a hex string + * @return SHA-256 digest as a hexadecimal string * @since 1.4 */ public static String sha256Hex(final String data) { @@ -691,10 +691,10 @@ public static byte[] sha3_224(final String data) { } /** - * Calculates the SHA3-224 digest and returns the value as a hex string. + * Calculates the SHA3-224 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-224 digest as a hex string + * @return SHA3-224 digest as a hexadecimal string * @since 1.12 */ public static String sha3_224Hex(final byte[] data) { @@ -702,10 +702,10 @@ public static String sha3_224Hex(final byte[] data) { } /** - * Calculates the SHA3-224 digest and returns the value as a hex string. + * Calculates the SHA3-224 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-224 digest as a hex string + * @return SHA3-224 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.12 */ @@ -714,10 +714,10 @@ public static String sha3_224Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA3-224 digest and returns the value as a hex string. + * Calculates the SHA3-224 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-224 digest as a hex string + * @return SHA3-224 digest as a hexadecimal string * @since 1.12 */ public static String sha3_224Hex(final String data) { @@ -759,10 +759,10 @@ public static byte[] sha3_256(final String data) { } /** - * Calculates the SHA3-256 digest and returns the value as a hex string. + * Calculates the SHA3-256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-256 digest as a hex string + * @return SHA3-256 digest as a hexadecimal string * @since 1.12 */ public static String sha3_256Hex(final byte[] data) { @@ -770,10 +770,10 @@ public static String sha3_256Hex(final byte[] data) { } /** - * Calculates the SHA3-256 digest and returns the value as a hex string. + * Calculates the SHA3-256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-256 digest as a hex string + * @return SHA3-256 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.12 */ @@ -782,10 +782,10 @@ public static String sha3_256Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA3-256 digest and returns the value as a hex string. + * Calculates the SHA3-256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-256 digest as a hex string + * @return SHA3-256 digest as a hexadecimal string * @since 1.12 */ public static String sha3_256Hex(final String data) { @@ -827,10 +827,10 @@ public static byte[] sha3_384(final String data) { } /** - * Calculates the SHA3-384 digest and returns the value as a hex string. + * Calculates the SHA3-384 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-384 digest as a hex string + * @return SHA3-384 digest as a hexadecimal string * @since 1.12 */ public static String sha3_384Hex(final byte[] data) { @@ -838,10 +838,10 @@ public static String sha3_384Hex(final byte[] data) { } /** - * Calculates the SHA3-384 digest and returns the value as a hex string. + * Calculates the SHA3-384 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-384 digest as a hex string + * @return SHA3-384 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.12 */ @@ -850,10 +850,10 @@ public static String sha3_384Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA3-384 digest and returns the value as a hex string. + * Calculates the SHA3-384 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-384 digest as a hex string + * @return SHA3-384 digest as a hexadecimal string * @since 1.12 */ public static String sha3_384Hex(final String data) { @@ -895,10 +895,10 @@ public static byte[] sha3_512(final String data) { } /** - * Calculates the SHA3-512 digest and returns the value as a hex string. + * Calculates the SHA3-512 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-512 digest as a hex string + * @return SHA3-512 digest as a hexadecimal string * @since 1.12 */ public static String sha3_512Hex(final byte[] data) { @@ -906,10 +906,10 @@ public static String sha3_512Hex(final byte[] data) { } /** - * Calculates the SHA3-512 digest and returns the value as a hex string. + * Calculates the SHA3-512 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-512 digest as a hex string + * @return SHA3-512 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.12 */ @@ -918,10 +918,10 @@ public static String sha3_512Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA3-512 digest and returns the value as a hex string. + * Calculates the SHA3-512 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA3-512 digest as a hex string + * @return SHA3-512 digest as a hexadecimal string * @since 1.12 */ public static String sha3_512Hex(final String data) { @@ -963,10 +963,10 @@ public static byte[] sha384(final String data) { } /** - * Calculates the SHA-384 digest and returns the value as a hex string. + * Calculates the SHA-384 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-384 digest as a hex string + * @return SHA-384 digest as a hexadecimal string * @since 1.4 */ public static String sha384Hex(final byte[] data) { @@ -974,10 +974,10 @@ public static String sha384Hex(final byte[] data) { } /** - * Calculates the SHA-384 digest and returns the value as a hex string. + * Calculates the SHA-384 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-384 digest as a hex string + * @return SHA-384 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.4 */ @@ -986,10 +986,10 @@ public static String sha384Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA-384 digest and returns the value as a hex string. + * Calculates the SHA-384 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-384 digest as a hex string + * @return SHA-384 digest as a hexadecimal string * @since 1.4 */ public static String sha384Hex(final String data) { @@ -1065,10 +1065,10 @@ public static byte[] sha512_224(final String data) { } /** - * Calculates the SHA-512/224 digest and returns the value as a hex string. + * Calculates the SHA-512/224 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512/224 digest as a hex string + * @return SHA-512/224 digest as a hexadecimal string * @since 1.14 */ public static String sha512_224Hex(final byte[] data) { @@ -1076,10 +1076,10 @@ public static String sha512_224Hex(final byte[] data) { } /** - * Calculates the SHA-512/224 digest and returns the value as a hex string. + * Calculates the SHA-512/224 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512/224 digest as a hex string + * @return SHA-512/224 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.14 */ @@ -1088,10 +1088,10 @@ public static String sha512_224Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA-512/224 digest and returns the value as a hex string. + * Calculates the SHA-512/224 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512/224 digest as a hex string + * @return SHA-512/224 digest as a hexadecimal string * @since 1.14 */ public static String sha512_224Hex(final String data) { @@ -1133,10 +1133,10 @@ public static byte[] sha512_256(final String data) { } /** - * Calculates the SHA-512/256 digest and returns the value as a hex string. + * Calculates the SHA-512/256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512/256 digest as a hex string + * @return SHA-512/256 digest as a hexadecimal string * @since 1.14 */ public static String sha512_256Hex(final byte[] data) { @@ -1144,10 +1144,10 @@ public static String sha512_256Hex(final byte[] data) { } /** - * Calculates the SHA-512/256 digest and returns the value as a hex string. + * Calculates the SHA-512/256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512/256 digest as a hex string + * @return SHA-512/256 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.14 */ @@ -1156,10 +1156,10 @@ public static String sha512_256Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA-512/256 digest and returns the value as a hex string. + * Calculates the SHA-512/256 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512/256 digest as a hex string + * @return SHA-512/256 digest as a hexadecimal string * @since 1.14 */ public static String sha512_256Hex(final String data) { @@ -1167,10 +1167,10 @@ public static String sha512_256Hex(final String data) { } /** - * Calculates the SHA-512 digest and returns the value as a hex string. + * Calculates the SHA-512 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512 digest as a hex string + * @return SHA-512 digest as a hexadecimal string * @since 1.4 */ public static String sha512Hex(final byte[] data) { @@ -1178,10 +1178,10 @@ public static String sha512Hex(final byte[] data) { } /** - * Calculates the SHA-512 digest and returns the value as a hex string. + * Calculates the SHA-512 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512 digest as a hex string + * @return SHA-512 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.4 */ @@ -1190,10 +1190,10 @@ public static String sha512Hex(final InputStream data) throws IOException { } /** - * Calculates the SHA-512 digest and returns the value as a hex string. + * Calculates the SHA-512 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-512 digest as a hex string + * @return SHA-512 digest as a hexadecimal string * @since 1.4 */ public static String sha512Hex(final String data) { @@ -1201,10 +1201,10 @@ public static String sha512Hex(final String data) { } /** - * Calculates the SHA-1 digest and returns the value as a hex string. + * Calculates the SHA-1 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-1 digest as a hex string + * @return SHA-1 digest as a hexadecimal string * @deprecated (1.11) Use {@link #sha1Hex(byte[])} */ @Deprecated @@ -1213,10 +1213,10 @@ public static String shaHex(final byte[] data) { } /** - * Calculates the SHA-1 digest and returns the value as a hex string. + * Calculates the SHA-1 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-1 digest as a hex string + * @return SHA-1 digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.4 * @deprecated (1.11) Use {@link #sha1Hex(InputStream)} @@ -1227,10 +1227,10 @@ public static String shaHex(final InputStream data) throws IOException { } /** - * Calculates the SHA-1 digest and returns the value as a hex string. + * Calculates the SHA-1 digest and returns the value as a hexadecimal string. * * @param data Data to digest - * @return SHA-1 digest as a hex string + * @return SHA-1 digest as a hexadecimal string * @deprecated (1.11) Use {@link #sha1Hex(String)} */ @Deprecated @@ -1371,7 +1371,7 @@ public static MessageDigest updateDigest(final MessageDigest messageDigest, fina /** * Preserves binary compatibility only. As for previous versions does not provide useful behavior - * + * * @deprecated since 1.11; only useful to preserve binary compatibility */ @Deprecated @@ -1480,7 +1480,7 @@ public byte[] digest(final String data) { * Reads through a byte array and returns the digest for the data. * * @param data Data to digest - * @return the digest as a hex string + * @return the digest as a hexadecimal string * @since 1.11 */ public String digestAsHex(final byte[] data) { @@ -1491,7 +1491,7 @@ public String digestAsHex(final byte[] data) { * Reads through a ByteBuffer and returns the digest for the data * * @param data Data to digest - * @return the digest as a hex string + * @return the digest as a hexadecimal string * * @since 1.11 */ @@ -1503,7 +1503,7 @@ public String digestAsHex(final ByteBuffer data) { * Reads through a File and returns the digest for the data * * @param data Data to digest - * @return the digest as a hex string + * @return the digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.11 */ @@ -1515,7 +1515,7 @@ public String digestAsHex(final File data) throws IOException { * Reads through an InputStream and returns the digest for the data * * @param data Data to digest - * @return the digest as a hex string + * @return the digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.11 */ @@ -1528,7 +1528,7 @@ public String digestAsHex(final InputStream data) throws IOException { * * @param data Data to digest * @param options options How to open the file - * @return the digest as a hex string + * @return the digest as a hexadecimal string * @throws IOException On error reading from the stream * @since 1.11 */ @@ -1540,7 +1540,7 @@ public String digestAsHex(final Path data, final OpenOption... options) throws I * Reads through a byte array and returns the digest for the data. * * @param data Data to digest treated as UTF-8 string - * @return the digest as a hex string + * @return the digest as a hexadecimal string * @since 1.11 */ public String digestAsHex(final String data) { @@ -1549,7 +1549,7 @@ public String digestAsHex(final String data) { /** * Returns the message digest instance. - * + * * @return the message digest instance * @since 1.11 */ diff --git a/src/main/java/org/apache/commons/codec/digest/HmacUtils.java b/src/main/java/org/apache/commons/codec/digest/HmacUtils.java index 4e1c9dfbe8..21cb7e0084 100644 --- a/src/main/java/org/apache/commons/codec/digest/HmacUtils.java +++ b/src/main/java/org/apache/commons/codec/digest/HmacUtils.java @@ -302,13 +302,13 @@ public static byte[] hmacMd5(final String key, final String valueToDigest) { } /** - * Returns a HmacMD5 Message Authentication Code (MAC) as a hex string (lowercase) for the given key and value. + * Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacMD5 MAC for the given key and value as a hex string (lowercase) + * @return HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_MD5, byte[]).hmacHex(byte[])} @@ -319,7 +319,7 @@ public static String hmacMd5Hex(final byte[] key, final byte[] valueToDigest) { } /** - * Returns a HmacMD5 Message Authentication Code (MAC) as a hex string (lowercase) for the given key and value. + * Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) @@ -328,7 +328,7 @@ public static String hmacMd5Hex(final byte[] key, final byte[] valueToDigest) { *

* The InputStream must not be null and will not be closed *

- * @return HmacMD5 MAC for the given key and value as a hex string (lowercase) + * @return HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException @@ -341,13 +341,13 @@ public static String hmacMd5Hex(final byte[] key, final InputStream valueToDiges } /** - * Returns a HmacMD5 Message Authentication Code (MAC) as a hex string (lowercase) for the given key and value. + * Returns a HmacMD5 Message Authentication Code (MAC) as a hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacMD5 MAC for the given key and value as a hex string (lowercase) + * @return HmacMD5 MAC for the given key and value as a hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_MD5, String).hmacHex(String)} @@ -416,13 +416,13 @@ public static byte[] hmacSha1(final String key, final String valueToDigest) { } /** - * Returns a HmacSHA1 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacSHA1 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_1, byte[]).hmacHex(byte[])} @@ -433,7 +433,7 @@ public static String hmacSha1Hex(final byte[] key, final byte[] valueToDigest) { } /** - * Returns a HmacSHA1 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) @@ -442,7 +442,7 @@ public static String hmacSha1Hex(final byte[] key, final byte[] valueToDigest) { *

* The InputStream must not be null and will not be closed *

- * @return HmacSHA1 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException @@ -455,13 +455,13 @@ public static String hmacSha1Hex(final byte[] key, final InputStream valueToDige } /** - * Returns a HmacSHA1 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA1 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacSHA1 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA1 MAC for the given key and value as hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_1, String).hmacHex(String)} @@ -528,13 +528,13 @@ public static byte[] hmacSha256(final String key, final String valueToDigest) { } /** - * Returns a HmacSHA256 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacSHA256 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_256, byte[]).hmacHex(byte[])} @@ -545,7 +545,7 @@ public static String hmacSha256Hex(final byte[] key, final byte[] valueToDigest) } /** - * Returns a HmacSHA256 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) @@ -554,7 +554,7 @@ public static String hmacSha256Hex(final byte[] key, final byte[] valueToDigest) *

* The InputStream must not be null and will not be closed *

- * @return HmacSHA256 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException @@ -567,13 +567,13 @@ public static String hmacSha256Hex(final byte[] key, final InputStream valueToDi } /** - * Returns a HmacSHA256 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA256 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacSHA256 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA256 MAC for the given key and value as hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_256, String).hmacHex(String)} @@ -642,13 +642,13 @@ public static byte[] hmacSha384(final String key, final String valueToDigest) { } /** - * Returns a HmacSHA384 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacSHA384 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_384, byte[]).hmacHex(byte[])} @@ -659,7 +659,7 @@ public static String hmacSha384Hex(final byte[] key, final byte[] valueToDigest) } /** - * Returns a HmacSHA384 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) @@ -668,7 +668,7 @@ public static String hmacSha384Hex(final byte[] key, final byte[] valueToDigest) *

* The InputStream must not be null and will not be closed *

- * @return HmacSHA384 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException @@ -681,13 +681,13 @@ public static String hmacSha384Hex(final byte[] key, final InputStream valueToDi } /** - * Returns a HmacSHA384 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA384 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacSHA384 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA384 MAC for the given key and value as hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_384, String).hmacHex(String)} @@ -756,13 +756,13 @@ public static byte[] hmacSha512(final String key, final String valueToDigest) { } /** - * Returns a HmacSHA512 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacSHA512 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_512, byte[]).hmacHex(byte[])} @@ -773,7 +773,7 @@ public static String hmacSha512Hex(final byte[] key, final byte[] valueToDigest) } /** - * Returns a HmacSHA512 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) @@ -782,7 +782,7 @@ public static String hmacSha512Hex(final byte[] key, final byte[] valueToDigest) *

* The InputStream must not be null and will not be closed *

- * @return HmacSHA512 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase) * @throws IOException * If an I/O error occurs. * @throws IllegalArgumentException @@ -795,13 +795,13 @@ public static String hmacSha512Hex(final byte[] key, final InputStream valueToDi } /** - * Returns a HmacSHA512 Message Authentication Code (MAC) as hex string (lowercase) for the given key and value. + * Returns a HmacSHA512 Message Authentication Code (MAC) as hexadecimal string (lowercase) for the given key and value. * * @param key * The key for the keyed digest (must not be null) * @param valueToDigest * The value (data) which should to digest (maybe empty or null) - * @return HmacSHA512 MAC for the given key and value as hex string (lowercase) + * @return HmacSHA512 MAC for the given key and value as hexadecimal string (lowercase) * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught or key is null or key is invalid. * @deprecated (1.11) Use {@code new HmacUtils(HmacAlgorithms.HMAC_SHA_512, String).hmacHex(String)} @@ -955,7 +955,7 @@ public byte[] hmac(final byte[] valueToDigest) { * Returns the digest for the input data. * * @param valueToDigest the input to use - * @return the digest as a hex String + * @return the digest as a hexadecimal String * @since 1.11 */ public String hmacHex(final byte[] valueToDigest) { @@ -977,7 +977,7 @@ public byte[] hmac(final String valueToDigest) { * Returns the digest for the input data. * * @param valueToDigest the input to use, treated as UTF-8 - * @return the digest as a hex String + * @return the digest as a hexadecimal String * @since 1.11 */ public String hmacHex(final String valueToDigest) { @@ -1000,7 +1000,7 @@ public byte[] hmac(final ByteBuffer valueToDigest) { * Returns the digest for the input data. * * @param valueToDigest the input to use - * @return the digest as a hex String + * @return the digest as a hexadecimal String * @since 1.11 */ public String hmacHex(final ByteBuffer valueToDigest) { @@ -1038,7 +1038,7 @@ public byte[] hmac(final InputStream valueToDigest) throws IOException { *

* The InputStream must not be null and will not be closed *

- * @return the digest as a hex String + * @return the digest as a hexadecimal String * @throws IOException * If an I/O error occurs. * @since 1.11 @@ -1066,7 +1066,7 @@ public byte[] hmac(final File valueToDigest) throws IOException { * Returns the digest for the file. * * @param valueToDigest the file to use - * @return the digest as a hex String + * @return the digest as a hexadecimal String * @throws IOException * If an I/O error occurs. * @since 1.11 diff --git a/src/main/java/org/apache/commons/codec/net/Utils.java b/src/main/java/org/apache/commons/codec/net/Utils.java index 256bc593f0..3d3c4f1132 100644 --- a/src/main/java/org/apache/commons/codec/net/Utils.java +++ b/src/main/java/org/apache/commons/codec/net/Utils.java @@ -52,10 +52,10 @@ static int digit16(final byte b) throws DecoderException { } /** - * Returns the upper case hex digit of the lower 4 bits of the int. + * Returns the upper case hexadecimal digit of the lower 4 bits of the int. * * @param b the input int - * @return the upper case hex digit of the lower 4 bits of the int. + * @return the upper case hexadecimal digit of the lower 4 bits of the int. */ static char hexDigit(final int b) { return Character.toUpperCase(Character.forDigit(b & 0xF, RADIX)); 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 189df6bf3c..6a694f19cc 100644 --- a/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java +++ b/src/test/java/org/apache/commons/codec/digest/DigestUtilsTest.java @@ -167,7 +167,7 @@ public void testMd2Hex() throws IOException { } /** - * An MD2 hash converted to hex should always be 32 characters. + * An MD2 hash converted to hexadecimal should always be 32 characters. */ @Test public void testMd2HexLength() { @@ -220,7 +220,7 @@ public void testMd5Hex() throws IOException { } /** - * An MD5 hash converted to hex should always be 32 characters. + * An MD5 hash converted to hexadecimal should always be 32 characters. */ @Test public void testMd5HexLengthForBytes() {