public class DigestUtilsHelper
extends java.lang.Object
Constructor and Description |
---|
DigestUtilsHelper() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
decodeHex(char[] data)
Converts an array of characters representing hexadecimal values into an array of bytes of those same values.
|
static byte[] |
decodeHexString(java.lang.String data)
Converts a String into an array of bytes.
|
static char[] |
encodeHex(byte[] data)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
static char[] |
encodeHex(byte[] data,
boolean toLowerCase)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
protected static char[] |
encodeHex(byte[] data,
char[] toDigits)
Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
|
static java.lang.String |
encodeHexString(byte[] data)
Converts an array of bytes into a String representing the hexadecimal values of each byte in order.
|
static byte[] |
getBytesUtf8(java.lang.String string)
Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte
array.
|
static java.security.MessageDigest |
getDigest(java.lang.String algorithm)
Returns a
MessageDigest for the given algorithm . |
static java.security.MessageDigest |
getMd5Digest()
Returns an MD5 MessageDigest.
|
static byte[] |
md5(byte[] data)
Calculates the MD5 digest and returns the value as a 16 element
byte[] . |
static byte[] |
md5(java.io.InputStream data)
Calculates the MD5 digest and returns the value as a 16 element
byte[] . |
static byte[] |
md5(java.lang.String data)
Calculates the MD5 digest and returns the value as a 16 element
byte[] . |
static java.lang.String |
md5Hex(java.io.InputStream data)
Calculates the MD5 digest and returns the value as a 32 character hex string.
|
static java.lang.String |
md5Hex(java.lang.String data)
Calculates the MD5 digest and returns the value as a 32 character hex string.
|
protected static int |
toDigit(char ch,
int index)
Converts a hexadecimal character to an integer.
|
public static java.lang.String md5Hex(java.lang.String data)
data
- data to digestpublic static java.lang.String md5Hex(java.io.InputStream data) throws java.io.IOException
data
- data stream to digest (will not be closed)java.io.IOException
public static byte[] md5(java.lang.String data)
byte[]
.data
- data to digestpublic static byte[] md5(byte[] data)
byte[]
.data
- data to digestpublic static byte[] md5(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- data stream to digest (will not be closed)java.io.IOException
public static java.security.MessageDigest getMd5Digest()
public static java.security.MessageDigest getDigest(java.lang.String algorithm)
MessageDigest
for the given algorithm
.algorithm
- java.lang.IllegalArgumentException
public static byte[] getBytesUtf8(java.lang.String string)
string
- the String to encode, may be null
null
if the input string was null
public static java.lang.String encodeHexString(byte[] data)
data
- a byte[] to convert to Hex characterspublic static char[] encodeHex(byte[] data)
data
- a byte[] to convert to Hex characterspublic static char[] encodeHex(byte[] data, boolean toLowerCase)
data
- a byte[] to convert to Hex characterstoLowerCase
- true
converts to lowercase, false
to uppercaseprotected static char[] encodeHex(byte[] data, char[] toDigits)
data
- a byte[] to convert to Hex characterstoDigits
- the output alphabetpublic static byte[] decodeHexString(java.lang.String data) throws java.lang.IllegalArgumentException
data
- a byte[] to convert to Hex charactersjava.lang.IllegalArgumentException
public static byte[] decodeHex(char[] data) throws java.lang.IllegalArgumentException
data
- An array of characters containing hexadecimal digitsjava.lang.IllegalArgumentException
protected static int toDigit(char ch, int index) throws java.lang.IllegalArgumentException
ch
- A character to convert to an integer digitindex
- The index of the character in the sourcejava.lang.IllegalArgumentException
Copyright © 2005-2021 Potix Corporation. All Rights Reserved.