|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sibvisions.util.SecureHash
public class SecureHash
The SecureHash
class provides the functionality of a message digest algorithm,
such as MD5 or SHA. Message digests are secure one-way hash functions that take
arbitrary-sized data and output a fixed-length hash value.
MessageDigest
Field Summary | |
---|---|
static String |
MD2
the MD2 hash algorithm. |
static String |
MD4
the MD4 hash algorithm. |
static String |
MD5
the MD5 hash algorithm. |
static String |
SHA
the SHA hash algorithm. |
static String |
SHA_256
the SHA-256 hash algorithm. |
static String |
SHA_384
the SHA-384 hash algorithm. |
static String |
SHA_512
the SHA-512 hash algorithm. |
Constructor Summary | |
---|---|
SecureHash(String pAlgorithm)
Creates a new instance of SecureHash for a specific hash algorithm. |
Method Summary | |
---|---|
void |
add(byte[] pData)
Adds data to the digest. |
void |
add(InputStream pData)
Adds data to the digest. |
String |
getHash()
Gets the current hash. |
static String |
getHash(String pAlgorithm,
byte[] pData)
Gets the hash of specific data. |
static String |
getHash(String pAlgorithm,
InputStream pData)
Gets the hash of all content read from an InputStream . |
byte[] |
getRawHash()
Gets the current raw hash. |
static byte[] |
getRawHash(String pAlgorithm,
byte[] pData)
Gets the raw hash of specific data. |
static byte[] |
getRawHash(String pAlgorithm,
InputStream pData)
Gets the raw hash of all content read from an InputStream . |
void |
reset()
Resets the digest. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String MD2
public static final String MD4
public static final String MD5
public static final String SHA
public static final String SHA_256
public static final String SHA_384
public static final String SHA_512
Constructor Detail |
---|
public SecureHash(String pAlgorithm)
SecureHash
for a specific hash algorithm.
pAlgorithm
- the hash algorithm
MD5
SHA
Method Detail |
---|
public static String getHash(String pAlgorithm, InputStream pData) throws NoSuchAlgorithmException, IOException
InputStream
.
pAlgorithm
- the hash algorithmpData
- the data stream
NoSuchAlgorithmException
- specified algorithm is not available
IOException
- if an error occurs during reading from the streampublic static byte[] getRawHash(String pAlgorithm, InputStream pData) throws NoSuchAlgorithmException, IOException
InputStream
.
pAlgorithm
- the hash algorithmpData
- the data stream
NoSuchAlgorithmException
- specified algorithm is not available
IOException
- if an error occurs during reading from the streampublic static String getHash(String pAlgorithm, byte[] pData) throws NoSuchAlgorithmException
pAlgorithm
- the hash algorithmpData
- the data
NoSuchAlgorithmException
- specified algorithm is not availablepublic static byte[] getRawHash(String pAlgorithm, byte[] pData) throws NoSuchAlgorithmException
pAlgorithm
- the hash algorithmpData
- the data
NoSuchAlgorithmException
- specified algorithm is not availablepublic void add(InputStream pData) throws NoSuchAlgorithmException, IOException
pData
- the data stream
NoSuchAlgorithmException
NoSuchAlgorithmException
- specified algorithm is not available
IOException
- if an error occurs during reading from the streampublic void add(byte[] pData) throws NoSuchAlgorithmException
pData
- the data
NoSuchAlgorithmException
- specified algorithm is not availablepublic void reset()
public String getHash()
public byte[] getRawHash()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |