org.elasticsearch.common
Class Digest

java.lang.Object
  extended by org.elasticsearch.common.Digest

public class Digest
extends Object


Field Summary
static org.elasticsearch.common.Digest.NullDigest NULL_DIGEST
           
 
Constructor Summary
Digest()
           
 
Method Summary
static 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(InputStream data)
          Calculates the MD5 digest and returns the value as a 16 element byte[].
static byte[] md5(String data)
          Calculates the MD5 digest and returns the value as a 16 element byte[].
static String md5Hex(byte[] data)
          Calculates the MD5 digest and returns the value as a 32 character hex string.
static String md5Hex(InputStream data)
          Calculates the MD5 digest and returns the value as a 32 character hex string.
static String md5Hex(String data)
          Calculates the MD5 digest and returns the value as a 32 character hex string.
static String md5HexFromByteArray(byte[] data)
           
static byte[] md5HexToByteArray(String md5Hex)
           
static byte[] sha(byte[] data)
          Calculates the SHA-1 digest and returns the value as a byte[].
static byte[] sha(InputStream data)
          Calculates the SHA-1 digest and returns the value as a byte[].
static byte[] sha(String data)
          Calculates the SHA-1 digest and returns the value as a byte[].
static byte[] sha256(byte[] data)
          Calculates the SHA-256 digest and returns the value as a byte[].
static byte[] sha256(InputStream data)
          Calculates the SHA-256 digest and returns the value as a byte[].
static byte[] sha256(String data)
          Calculates the SHA-256 digest and returns the value as a byte[].
static String sha256Hex(byte[] data)
          Calculates the SHA-256 digest and returns the value as a hex string.
static String sha256Hex(InputStream data)
          Calculates the SHA-256 digest and returns the value as a hex string.
static String sha256Hex(String data)
          Calculates the SHA-256 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(InputStream data)
          Calculates the SHA-384 digest and returns the value as a byte[].
static byte[] sha384(String data)
          Calculates the SHA-384 digest and returns the value as a byte[].
static String sha384Hex(byte[] data)
          Calculates the SHA-384 digest and returns the value as a hex string.
static String sha384Hex(InputStream data)
          Calculates the SHA-384 digest and returns the value as a hex string.
static String sha384Hex(String data)
          Calculates the SHA-384 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(InputStream data)
          Calculates the SHA-512 digest and returns the value as a byte[].
static byte[] sha512(String data)
          Calculates the SHA-512 digest and returns the value as a byte[].
static String sha512Hex(byte[] data)
          Calculates the SHA-512 digest and returns the value as a hex string.
static String sha512Hex(InputStream data)
          Calculates the SHA-512 digest and returns the value as a hex string.
static String sha512Hex(String data)
          Calculates the SHA-512 digest and returns the value as a hex string.
static String shaHex(byte[] data)
          Calculates the SHA-1 digest and returns the value as a hex string.
static String shaHex(InputStream data)
          Calculates the SHA-1 digest and returns the value as a hex string.
static String shaHex(String data)
          Calculates the SHA-1 digest and returns the value as a hex string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_DIGEST

public static final org.elasticsearch.common.Digest.NullDigest NULL_DIGEST
Constructor Detail

Digest

public Digest()
Method Detail

getMd5Digest

public static MessageDigest getMd5Digest()
Returns an MD5 MessageDigest.

Returns:
An MD5 digest instance.
Throws:
RuntimeException - when a NoSuchAlgorithmException is caught.

md5

public static byte[] md5(byte[] data)
Calculates the MD5 digest and returns the value as a 16 element byte[].

Parameters:
data - Data to digest
Returns:
MD5 digest

md5

public static byte[] md5(InputStream data)
                  throws IOException
Calculates the MD5 digest and returns the value as a 16 element byte[].

Parameters:
data - Data to digest
Returns:
MD5 digest
Throws:
IOException - On error reading from the stream
Since:
1.4

md5

public static byte[] md5(String data)
Calculates the MD5 digest and returns the value as a 16 element byte[].

Parameters:
data - Data to digest
Returns:
MD5 digest

md5Hex

public static String md5Hex(byte[] data)
Calculates the MD5 digest and returns the value as a 32 character hex string.

Parameters:
data - Data to digest
Returns:
MD5 digest as a hex string

md5Hex

public static String md5Hex(InputStream data)
                     throws IOException
Calculates the MD5 digest and returns the value as a 32 character hex string.

Parameters:
data - Data to digest
Returns:
MD5 digest as a hex string
Throws:
IOException - On error reading from the stream
Since:
1.4

md5Hex

public static String md5Hex(String data)
Calculates the MD5 digest and returns the value as a 32 character hex string.

Parameters:
data - Data to digest
Returns:
MD5 digest as a hex string

md5HexToByteArray

public static byte[] md5HexToByteArray(String md5Hex)

md5HexFromByteArray

public static String md5HexFromByteArray(byte[] data)

sha

public static byte[] sha(byte[] data)
Calculates the SHA-1 digest and returns the value as a byte[].

Parameters:
data - Data to digest
Returns:
SHA-1 digest

sha

public static byte[] sha(InputStream data)
                  throws IOException
Calculates the SHA-1 digest and returns the value as a byte[].

Parameters:
data - Data to digest
Returns:
SHA-1 digest
Throws:
IOException - On error reading from the stream
Since:
1.4

sha

public static byte[] sha(String data)
Calculates the SHA-1 digest and returns the value as a byte[].

Parameters:
data - Data to digest
Returns:
SHA-1 digest

sha256

public static byte[] sha256(byte[] data)
Calculates the SHA-256 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-256 digest
Since:
1.4

sha256

public static byte[] sha256(InputStream data)
                     throws IOException
Calculates the SHA-256 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-256 digest
Throws:
IOException - On error reading from the stream
Since:
1.4

sha256

public static byte[] sha256(String data)
Calculates the SHA-256 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-256 digest
Since:
1.4

sha256Hex

public static String sha256Hex(byte[] data)
Calculates the SHA-256 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-256 digest as a hex string
Since:
1.4

sha256Hex

public static String sha256Hex(InputStream data)
                        throws IOException
Calculates the SHA-256 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-256 digest as a hex string
Throws:
IOException - On error reading from the stream
Since:
1.4

sha256Hex

public static String sha256Hex(String data)
Calculates the SHA-256 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-256 digest as a hex string
Since:
1.4

sha384

public static byte[] sha384(byte[] data)
Calculates the SHA-384 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-384 digest
Since:
1.4

sha384

public static byte[] sha384(InputStream data)
                     throws IOException
Calculates the SHA-384 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-384 digest
Throws:
IOException - On error reading from the stream
Since:
1.4

sha384

public static byte[] sha384(String data)
Calculates the SHA-384 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-384 digest
Since:
1.4

sha384Hex

public static String sha384Hex(byte[] data)
Calculates the SHA-384 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-384 digest as a hex string
Since:
1.4

sha384Hex

public static String sha384Hex(InputStream data)
                        throws IOException
Calculates the SHA-384 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-384 digest as a hex string
Throws:
IOException - On error reading from the stream
Since:
1.4

sha384Hex

public static String sha384Hex(String data)
Calculates the SHA-384 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-384 digest as a hex string
Since:
1.4

sha512

public static byte[] sha512(byte[] data)
Calculates the SHA-512 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-512 digest
Since:
1.4

sha512

public static byte[] sha512(InputStream data)
                     throws IOException
Calculates the SHA-512 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-512 digest
Throws:
IOException - On error reading from the stream
Since:
1.4

sha512

public static byte[] sha512(String data)
Calculates the SHA-512 digest and returns the value as a byte[].

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-512 digest
Since:
1.4

sha512Hex

public static String sha512Hex(byte[] data)
Calculates the SHA-512 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-512 digest as a hex string
Since:
1.4

sha512Hex

public static String sha512Hex(InputStream data)
                        throws IOException
Calculates the SHA-512 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-512 digest as a hex string
Throws:
IOException - On error reading from the stream
Since:
1.4

sha512Hex

public static String sha512Hex(String data)
Calculates the SHA-512 digest and returns the value as a hex string.

Throws a RuntimeException on JRE versions prior to 1.4.0.

Parameters:
data - Data to digest
Returns:
SHA-512 digest as a hex string
Since:
1.4

shaHex

public static String shaHex(byte[] data)
Calculates the SHA-1 digest and returns the value as a hex string.

Parameters:
data - Data to digest
Returns:
SHA-1 digest as a hex string

shaHex

public static String shaHex(InputStream data)
                     throws IOException
Calculates the SHA-1 digest and returns the value as a hex string.

Parameters:
data - Data to digest
Returns:
SHA-1 digest as a hex string
Throws:
IOException - On error reading from the stream
Since:
1.4

shaHex

public static String shaHex(String data)
Calculates the SHA-1 digest and returns the value as a hex string.

Parameters:
data - Data to digest
Returns:
SHA-1 digest as a hex string


Copyright © 2009-2012. All Rights Reserved.