public class DigestUtils
extends java.lang.Object
MessageDigest
tasks.
This class is immutable and thread-safe.
However the MessageDigest instances it creates generally won't be.
The MessageDigestAlgorithms
class provides constants for standard
digest algorithms that can be used with the getDigest(String)
method
and other methods that require the Digest algorithm name.
Note: the class has short-hand 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"));
MessageDigestAlgorithms
Constructor and Description |
---|
DigestUtils()
Deprecated.
since 1.11; only useful to preserve binary compatibility
|
DigestUtils(java.security.MessageDigest digest)
Creates an instance using the provided
MessageDigest parameter. |
DigestUtils(java.lang.String name)
Creates an instance using the provided
MessageDigest parameter. |
Modifier and Type | Method and Description |
---|---|
byte[] |
digest(byte[] data)
Reads through a byte array and returns the digest for the data.
|
byte[] |
digest(java.nio.ByteBuffer data)
Reads through a ByteBuffer and returns the digest for the data
|
byte[] |
digest(java.io.File data)
Reads through a File and returns the digest for the data
|
byte[] |
digest(java.io.InputStream data)
Reads through an InputStream and returns the digest for the data
|
static byte[] |
digest(java.security.MessageDigest messageDigest,
byte[] data)
Reads through a byte array and returns the digest for the data.
|
static byte[] |
digest(java.security.MessageDigest messageDigest,
java.nio.ByteBuffer data)
Reads through a ByteBuffer and returns the digest for the data
|
static byte[] |
digest(java.security.MessageDigest messageDigest,
java.io.File data)
Reads through a File and returns the digest for the data
|
static byte[] |
digest(java.security.MessageDigest messageDigest,
java.io.InputStream data)
Reads through an InputStream and returns the digest for the data
|
static byte[] |
digest(java.security.MessageDigest messageDigest,
java.nio.file.Path data,
java.nio.file.OpenOption... options)
Reads through a File and returns the digest for the data
|
static byte[] |
digest(java.security.MessageDigest messageDigest,
java.io.RandomAccessFile data)
Reads through a RandomAccessFile using non-blocking-io (NIO) and returns the digest for the data
|
byte[] |
digest(java.nio.file.Path data,
java.nio.file.OpenOption... options)
Reads through a File and returns the digest for the data
|
byte[] |
digest(java.lang.String data)
Reads through a byte array and returns the digest for the data.
|
java.lang.String |
digestAsHex(byte[] data)
Reads through a byte array and returns the digest for the data.
|
java.lang.String |
digestAsHex(java.nio.ByteBuffer data)
Reads through a ByteBuffer and returns the digest for the data
|
java.lang.String |
digestAsHex(java.io.File data)
Reads through a File and returns the digest for the data
|
java.lang.String |
digestAsHex(java.io.InputStream data)
Reads through an InputStream and returns the digest for the data
|
java.lang.String |
digestAsHex(java.nio.file.Path data,
java.nio.file.OpenOption... options)
Reads through a File and returns the digest for the data
|
java.lang.String |
digestAsHex(java.lang.String data)
Reads through a byte array and returns the digest for the data.
|
static java.security.MessageDigest |
getDigest(java.lang.String algorithm)
Returns a
MessageDigest for the given algorithm . |
static java.security.MessageDigest |
getDigest(java.lang.String algorithm,
java.security.MessageDigest defaultMessageDigest)
Returns a
MessageDigest for the given algorithm or a default if there is a problem
getting the algorithm. |
static java.security.MessageDigest |
getMd2Digest()
Returns an MD2 MessageDigest.
|
static java.security.MessageDigest |
getMd5Digest()
Returns an MD5 MessageDigest.
|
java.security.MessageDigest |
getMessageDigest()
Returns the message digest instance.
|
static java.security.MessageDigest |
getSha1Digest()
Returns an SHA-1 digest.
|
static java.security.MessageDigest |
getSha256Digest()
Returns an SHA-256 digest.
|
static java.security.MessageDigest |
getSha3_224Digest()
Returns an SHA3-224 digest.
|
static java.security.MessageDigest |
getSha3_256Digest()
Returns an SHA3-256 digest.
|
static java.security.MessageDigest |
getSha3_384Digest()
Returns an SHA3-384 digest.
|
static java.security.MessageDigest |
getSha3_512Digest()
Returns an SHA3-512 digest.
|
static java.security.MessageDigest |
getSha384Digest()
Returns an SHA-384 digest.
|
static java.security.MessageDigest |
getSha512_224Digest()
Returns an SHA-512/224 digest.
|
static java.security.MessageDigest |
getSha512_256Digest()
Returns an SHA-512/256 digest.
|
static java.security.MessageDigest |
getSha512Digest()
Returns an SHA-512 digest.
|
static java.security.MessageDigest |
getShaDigest()
Deprecated.
(1.11) Use
getSha1Digest() |
static boolean |
isAvailable(java.lang.String messageDigestAlgorithm)
Test whether the algorithm is supported.
|
static byte[] |
md2(byte[] data)
Calculates the MD2 digest and returns the value as a 16 element
byte[] . |
static byte[] |
md2(java.io.InputStream data)
Calculates the MD2 digest and returns the value as a 16 element
byte[] . |
static byte[] |
md2(java.lang.String data)
Calculates the MD2 digest and returns the value as a 16 element
byte[] . |
static java.lang.String |
md2Hex(byte[] data)
Calculates the MD2 digest and returns the value as a 32 character hex string.
|
static java.lang.String |
md2Hex(java.io.InputStream data)
Calculates the MD2 digest and returns the value as a 32 character hex string.
|
static java.lang.String |
md2Hex(java.lang.String data)
Calculates the MD2 digest and returns the value as a 32 character hex string.
|
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(byte[] data)
Calculates the MD5 digest and returns the value as a 32 character hex string.
|
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.
|
static byte[] |
sha(byte[] data)
Deprecated.
(1.11) Use
sha1(byte[]) |
static byte[] |
sha(java.io.InputStream data)
Deprecated.
(1.11) Use
sha1(InputStream) |
static byte[] |
sha(java.lang.String data)
Deprecated.
(1.11) Use
sha1(String) |
static byte[] |
sha1(byte[] data)
Calculates the SHA-1 digest and returns the value as a
byte[] . |
static byte[] |
sha1(java.io.InputStream data)
Calculates the SHA-1 digest and returns the value as a
byte[] . |
static byte[] |
sha1(java.lang.String data)
Calculates the SHA-1 digest and returns the value as a
byte[] . |
static java.lang.String |
sha1Hex(byte[] data)
Calculates the SHA-1 digest and returns the value as a hex string.
|
static java.lang.String |
sha1Hex(java.io.InputStream data)
Calculates the SHA-1 digest and returns the value as a hex string.
|
static java.lang.String |
sha1Hex(java.lang.String data)
Calculates the SHA-1 digest and returns the value as a hex string.
|
static byte[] |
sha256(byte[] data)
Calculates the SHA-256 digest and returns the value as a
byte[] . |
static byte[] |
sha256(java.io.InputStream data)
Calculates the SHA-256 digest and returns the value as a
byte[] . |
static byte[] |
sha256(java.lang.String data)
Calculates the SHA-256 digest and returns the value as a
byte[] . |
static java.lang.String |
sha256Hex(byte[] data)
Calculates the SHA-256 digest and returns the value as a hex string.
|
static java.lang.String |
sha256Hex(java.io.InputStream data)
Calculates the SHA-256 digest and returns the value as a hex string.
|
static java.lang.String |
sha256Hex(java.lang.String data)
Calculates the SHA-256 digest and returns the value as a hex string.
|
static byte[] |
sha3_224(byte[] data)
Calculates the SHA3-224 digest and returns the value as a
byte[] . |
static byte[] |
sha3_224(java.io.InputStream data)
Calculates the SHA3-224 digest and returns the value as a
byte[] . |
static byte[] |
sha3_224(java.lang.String data)
Calculates the SHA3-224 digest and returns the value as a
byte[] . |
static java.lang.String |
sha3_224Hex(byte[] data)
Calculates the SHA3-224 digest and returns the value as a hex string.
|
static java.lang.String |
sha3_224Hex(java.io.InputStream data)
Calculates the SHA3-224 digest and returns the value as a hex string.
|
static java.lang.String |
sha3_224Hex(java.lang.String data)
Calculates the SHA3-224 digest and returns the value as a hex string.
|
static byte[] |
sha3_256(byte[] data)
Calculates the SHA3-256 digest and returns the value as a
byte[] . |
static byte[] |
sha3_256(java.io.InputStream data)
Calculates the SHA3-256 digest and returns the value as a
byte[] . |
static byte[] |
sha3_256(java.lang.String data)
Calculates the SHA3-256 digest and returns the value as a
byte[] . |
static java.lang.String |
sha3_256Hex(byte[] data)
Calculates the SHA3-256 digest and returns the value as a hex string.
|
static java.lang.String |
sha3_256Hex(java.io.InputStream data)
Calculates the SHA3-256 digest and returns the value as a hex string.
|
static java.lang.String |
sha3_256Hex(java.lang.String data)
Calculates the SHA3-256 digest and returns the value as a hex string.
|
static byte[] |
sha3_384(byte[] data)
Calculates the SHA3-384 digest and returns the value as a
byte[] . |
static byte[] |
sha3_384(java.io.InputStream data)
Calculates the SHA3-384 digest and returns the value as a
byte[] . |
static byte[] |
sha3_384(java.lang.String data)
Calculates the SHA3-384 digest and returns the value as a
byte[] . |
static java.lang.String |
sha3_384Hex(byte[] data)
Calculates the SHA3-384 digest and returns the value as a hex string.
|
static java.lang.String |
sha3_384Hex(java.io.InputStream data)
Calculates the SHA3-384 digest and returns the value as a hex string.
|
static java.lang.String |
sha3_384Hex(java.lang.String data)
Calculates the SHA3-384 digest and returns the value as a hex string.
|
static byte[] |
sha3_512(byte[] data)
Calculates the SHA3-512 digest and returns the value as a
byte[] . |
static byte[] |
sha3_512(java.io.InputStream data)
Calculates the SHA3-512 digest and returns the value as a
byte[] . |
static byte[] |
sha3_512(java.lang.String data)
Calculates the SHA3-512 digest and returns the value as a
byte[] . |
static java.lang.String |
sha3_512Hex(byte[] data)
Calculates the SHA3-512 digest and returns the value as a hex string.
|
static java.lang.String |
sha3_512Hex(java.io.InputStream data)
Calculates the SHA3-512 digest and returns the value as a hex string.
|
static java.lang.String |
sha3_512Hex(java.lang.String data)
Calculates the SHA3-512 digest and returns the value as a hex string.
|
static byte[] |
sha384(byte[] data)
Calculates the SHA-384 digest and returns the value as a
byte[] . |
static byte[] |
sha384(java.io.InputStream data)
Calculates the SHA-384 digest and returns the value as a
byte[] . |
static byte[] |
sha384(java.lang.String data)
Calculates the SHA-384 digest and returns the value as a
byte[] . |
static java.lang.String |
sha384Hex(byte[] data)
Calculates the SHA-384 digest and returns the value as a hex string.
|
static java.lang.String |
sha384Hex(java.io.InputStream data)
Calculates the SHA-384 digest and returns the value as a hex string.
|
static java.lang.String |
sha384Hex(java.lang.String data)
Calculates the SHA-384 digest and returns the value as a hex string.
|
static byte[] |
sha512_224(byte[] data)
Calculates the SHA-512/224 digest and returns the value as a
byte[] . |
static byte[] |
sha512_224(java.io.InputStream data)
Calculates the SHA-512/224 digest and returns the value as a
byte[] . |
static byte[] |
sha512_224(java.lang.String data)
Calculates the SHA-512/224 digest and returns the value as a
byte[] . |
static java.lang.String |
sha512_224Hex(byte[] data)
Calculates the SHA-512/224 digest and returns the value as a hex string.
|
static java.lang.String |
sha512_224Hex(java.io.InputStream data)
Calculates the SHA-512/224 digest and returns the value as a hex string.
|
static java.lang.String |
sha512_224Hex(java.lang.String data)
Calculates the SHA-512/224 digest and returns the value as a hex string.
|
static byte[] |
sha512_256(byte[] data)
Calculates the SHA-512/256 digest and returns the value as a
byte[] . |
static byte[] |
sha512_256(java.io.InputStream data)
Calculates the SHA-512/256 digest and returns the value as a
byte[] . |
static byte[] |
sha512_256(java.lang.String data)
Calculates the SHA-512/256 digest and returns the value as a
byte[] . |
static java.lang.String |
sha512_256Hex(byte[] data)
Calculates the SHA-512/256 digest and returns the value as a hex string.
|
static java.lang.String |
sha512_256Hex(java.io.InputStream data)
Calculates the SHA-512/256 digest and returns the value as a hex string.
|
static java.lang.String |
sha512_256Hex(java.lang.String data)
Calculates the SHA-512/256 digest and returns the value as a hex string.
|
static byte[] |
sha512(byte[] data)
Calculates the SHA-512 digest and returns the value as a
byte[] . |
static byte[] |
sha512(java.io.InputStream data)
Calculates the SHA-512 digest and returns the value as a
byte[] . |
static byte[] |
sha512(java.lang.String data)
Calculates the SHA-512 digest and returns the value as a
byte[] . |
static java.lang.String |
sha512Hex(byte[] data)
Calculates the SHA-512 digest and returns the value as a hex string.
|
static java.lang.String |
sha512Hex(java.io.InputStream data)
Calculates the SHA-512 digest and returns the value as a hex string.
|
static java.lang.String |
sha512Hex(java.lang.String data)
Calculates the SHA-512 digest and returns the value as a hex string.
|
static java.lang.String |
shaHex(byte[] data)
Deprecated.
(1.11) Use
sha1Hex(byte[]) |
static java.lang.String |
shaHex(java.io.InputStream data)
Deprecated.
(1.11) Use
sha1Hex(InputStream) |
static java.lang.String |
shaHex(java.lang.String data)
Deprecated.
(1.11) Use
sha1Hex(String) |
static java.security.MessageDigest |
updateDigest(java.security.MessageDigest messageDigest,
byte[] valueToDigest)
Updates the given
MessageDigest . |
static java.security.MessageDigest |
updateDigest(java.security.MessageDigest messageDigest,
java.nio.ByteBuffer valueToDigest)
Updates the given
MessageDigest . |
static java.security.MessageDigest |
updateDigest(java.security.MessageDigest digest,
java.io.File data)
Reads through a File and updates the digest for the data
|
static java.security.MessageDigest |
updateDigest(java.security.MessageDigest digest,
java.io.InputStream inputStream)
Reads through an InputStream and updates the digest for the data
|
static java.security.MessageDigest |
updateDigest(java.security.MessageDigest digest,
java.nio.file.Path path,
java.nio.file.OpenOption... options)
Reads through a Path and updates the digest for the data
|
static java.security.MessageDigest |
updateDigest(java.security.MessageDigest digest,
java.io.RandomAccessFile data)
Reads through a RandomAccessFile and updates the digest for the data using non-blocking-io (NIO)
|
static java.security.MessageDigest |
updateDigest(java.security.MessageDigest messageDigest,
java.lang.String valueToDigest)
Updates the given
MessageDigest from a String (converted to bytes using UTF-8). |
@Deprecated public DigestUtils()
public DigestUtils(java.security.MessageDigest digest)
MessageDigest
parameter.
This can then be used to create digests using methods such as
digest(byte[])
and digestAsHex(File)
.digest
- the MessageDigest
to usepublic DigestUtils(java.lang.String name)
MessageDigest
parameter.
This can then be used to create digests using methods such as
digest(byte[])
and digestAsHex(File)
.name
- the name of the MessageDigest
to usejava.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught.getDigest(String)
public static byte[] digest(java.security.MessageDigest messageDigest, byte[] data)
messageDigest
- The MessageDigest to use (e.g. MD5)data
- Data to digestpublic static byte[] digest(java.security.MessageDigest messageDigest, java.nio.ByteBuffer data)
messageDigest
- The MessageDigest to use (e.g. MD5)data
- Data to digestpublic static byte[] digest(java.security.MessageDigest messageDigest, java.io.File data) throws java.io.IOException
messageDigest
- The MessageDigest to use (e.g. MD5)data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] digest(java.security.MessageDigest messageDigest, java.io.InputStream data) throws java.io.IOException
messageDigest
- The MessageDigest to use (e.g. MD5)data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] digest(java.security.MessageDigest messageDigest, java.nio.file.Path data, java.nio.file.OpenOption... options) throws java.io.IOException
messageDigest
- The MessageDigest to use (e.g. MD5)data
- Data to digestoptions
- options How to open the filejava.io.IOException
- On error reading from the streampublic static byte[] digest(java.security.MessageDigest messageDigest, java.io.RandomAccessFile data) throws java.io.IOException
messageDigest
- The MessageDigest to use (e.g. MD5)data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.security.MessageDigest getDigest(java.lang.String algorithm)
MessageDigest
for the given algorithm
.algorithm
- the name of the algorithm requested. See Appendix A in the Java Cryptography Architecture Reference Guide for information about standard
algorithm names.java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught.MessageDigest.getInstance(String)
public static java.security.MessageDigest getDigest(java.lang.String algorithm, java.security.MessageDigest defaultMessageDigest)
MessageDigest
for the given algorithm
or a default if there is a problem
getting the algorithm.algorithm
- the name of the algorithm requested. See
Appendix A in the Java Cryptography Architecture Reference Guide for information about standard
algorithm names.defaultMessageDigest
- The default MessageDigest.java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught.MessageDigest.getInstance(String)
public static java.security.MessageDigest getMd2Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should never happen because MD2 is a
built-in algorithmMessageDigestAlgorithms.MD2
public static java.security.MessageDigest getMd5Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should never happen because MD5 is a
built-in algorithmMessageDigestAlgorithms.MD5
public static java.security.MessageDigest getSha1Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should never happen because SHA-1 is a
built-in algorithmMessageDigestAlgorithms.SHA_1
public static java.security.MessageDigest getSha256Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should never happen because SHA-256 is a
built-in algorithmMessageDigestAlgorithms.SHA_256
public static java.security.MessageDigest getSha3_224Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should not happen on
Oracle Java 9 andgreater.MessageDigestAlgorithms.SHA3_224
public static java.security.MessageDigest getSha3_256Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should not happen on
Oracle Java 9 and greater.MessageDigestAlgorithms.SHA3_256
public static java.security.MessageDigest getSha3_384Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should not happen on
Oracle Java 9 and greater.MessageDigestAlgorithms.SHA3_384
public static java.security.MessageDigest getSha3_512Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should not happen
on Oracle Java 9 and greater.MessageDigestAlgorithms.SHA3_512
public static java.security.MessageDigest getSha384Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should never happen
because SHA-384 is a built-in algorithmMessageDigestAlgorithms.SHA_384
public static java.security.MessageDigest getSha512_224Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught.MessageDigestAlgorithms.SHA_512_224
public static java.security.MessageDigest getSha512_256Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught.MessageDigestAlgorithms.SHA_512_224
public static java.security.MessageDigest getSha512Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caught, which should never happen
because SHA-512 is a built-in algorithmMessageDigestAlgorithms.SHA_512
@Deprecated public static java.security.MessageDigest getShaDigest()
getSha1Digest()
java.lang.IllegalArgumentException
- when a NoSuchAlgorithmException
is caughtpublic static boolean isAvailable(java.lang.String messageDigestAlgorithm)
messageDigestAlgorithm
- the algorithm nametrue
if the algorithm can be foundpublic static byte[] md2(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] md2(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] md2(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String md2Hex(byte[] data)
data
- Data to digestpublic static java.lang.String md2Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String md2Hex(java.lang.String data)
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 to digestjava.io.IOException
- On error reading from the streampublic static byte[] md5(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String md5Hex(byte[] data)
data
- Data to digestpublic static java.lang.String md5Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String md5Hex(java.lang.String data)
data
- Data to digest@Deprecated public static byte[] sha(byte[] data)
sha1(byte[])
byte[]
.data
- Data to digest@Deprecated public static byte[] sha(java.io.InputStream data) throws java.io.IOException
sha1(InputStream)
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the stream@Deprecated public static byte[] sha(java.lang.String data)
sha1(String)
byte[]
.data
- Data to digestpublic static byte[] sha1(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha1(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha1(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha1Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha1Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha1Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha256(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha256(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha256(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha256Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha256Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha256Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha3_224(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha3_224(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha3_224(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha3_224Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha3_224Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha3_224Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha3_256(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha3_256(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha3_256(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha3_256Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha3_256Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha3_256Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha3_384(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha3_384(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha3_384(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha3_384Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha3_384Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha3_384Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha3_512(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha3_512(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha3_512(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha3_512Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha3_512Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha3_512Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha384(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha384(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha384(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha384Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha384Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha384Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha512(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha512(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha512(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static byte[] sha512_224(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha512_224(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha512_224(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha512_224Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha512_224Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha512_224Hex(java.lang.String data)
data
- Data to digestpublic static byte[] sha512_256(byte[] data)
byte[]
.data
- Data to digestpublic static byte[] sha512_256(java.io.InputStream data) throws java.io.IOException
byte[]
.data
- Data to digestjava.io.IOException
- On error reading from the streampublic static byte[] sha512_256(java.lang.String data)
byte[]
.data
- Data to digest; converted to bytes using StringUtils.getBytesUtf8(String)
public static java.lang.String sha512_256Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha512_256Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha512_256Hex(java.lang.String data)
data
- Data to digestpublic static java.lang.String sha512Hex(byte[] data)
data
- Data to digestpublic static java.lang.String sha512Hex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.lang.String sha512Hex(java.lang.String data)
data
- Data to digest@Deprecated public static java.lang.String shaHex(byte[] data)
sha1Hex(byte[])
data
- Data to digest@Deprecated public static java.lang.String shaHex(java.io.InputStream data) throws java.io.IOException
sha1Hex(InputStream)
data
- Data to digestjava.io.IOException
- On error reading from the stream@Deprecated public static java.lang.String shaHex(java.lang.String data)
sha1Hex(String)
data
- Data to digestpublic static java.security.MessageDigest updateDigest(java.security.MessageDigest messageDigest, byte[] valueToDigest)
MessageDigest
.messageDigest
- the MessageDigest
to updatevalueToDigest
- the value to update the MessageDigest
withMessageDigest
public static java.security.MessageDigest updateDigest(java.security.MessageDigest messageDigest, java.nio.ByteBuffer valueToDigest)
MessageDigest
.messageDigest
- the MessageDigest
to updatevalueToDigest
- the value to update the MessageDigest
withMessageDigest
public static java.security.MessageDigest updateDigest(java.security.MessageDigest digest, java.io.File data) throws java.io.IOException
digest
- The MessageDigest to use (e.g. MD5)data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.security.MessageDigest updateDigest(java.security.MessageDigest digest, java.io.InputStream inputStream) throws java.io.IOException
digest
- The MessageDigest to use (e.g. MD5)inputStream
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.security.MessageDigest updateDigest(java.security.MessageDigest digest, java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
digest
- The MessageDigest to use (e.g. MD5)path
- Data to digestoptions
- options How to open the filejava.io.IOException
- On error reading from the streampublic static java.security.MessageDigest updateDigest(java.security.MessageDigest digest, java.io.RandomAccessFile data) throws java.io.IOException
digest
- The MessageDigest to use (e.g. MD5)data
- Data to digestjava.io.IOException
- On error reading from the streampublic static java.security.MessageDigest updateDigest(java.security.MessageDigest messageDigest, java.lang.String valueToDigest)
MessageDigest
from a String (converted to bytes using UTF-8).
To update the digest using a different charset for the conversion,
convert the String to a byte array using
String.getBytes(java.nio.charset.Charset)
and pass that
to the updateDigest(MessageDigest, byte[])
method
messageDigest
- the MessageDigest
to updatevalueToDigest
- the value to update the MessageDigest
with;
converted to bytes using StringUtils.getBytesUtf8(String)
MessageDigest
public byte[] digest(byte[] data)
data
- Data to digestpublic byte[] digest(java.nio.ByteBuffer data)
data
- Data to digestpublic byte[] digest(java.io.File data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic byte[] digest(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic byte[] digest(java.nio.file.Path data, java.nio.file.OpenOption... options) throws java.io.IOException
data
- Data to digestoptions
- options How to open the filejava.io.IOException
- On error reading from the streampublic byte[] digest(java.lang.String data)
data
- Data to digest treated as UTF-8 stringpublic java.lang.String digestAsHex(byte[] data)
data
- Data to digestpublic java.lang.String digestAsHex(java.nio.ByteBuffer data)
data
- Data to digestpublic java.lang.String digestAsHex(java.io.File data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic java.lang.String digestAsHex(java.io.InputStream data) throws java.io.IOException
data
- Data to digestjava.io.IOException
- On error reading from the streampublic java.lang.String digestAsHex(java.nio.file.Path data, java.nio.file.OpenOption... options) throws java.io.IOException
data
- Data to digestoptions
- options How to open the filejava.io.IOException
- On error reading from the streampublic java.lang.String digestAsHex(java.lang.String data)
data
- Data to digest treated as UTF-8 stringpublic java.security.MessageDigest getMessageDigest()
Copyright © 2010 - 2020 Adobe. All Rights Reserved