|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.common.util.SecureHash
@Immutable public class SecureHash
A simple utility to generate various kinds of secure hashes.
Nested Class Summary | |
---|---|
static class |
SecureHash.Algorithm
Commonly-used hashing algorithms. |
static class |
SecureHash.HashingInputStream
|
static class |
SecureHash.HashingReader
|
Constructor Summary | |
---|---|
SecureHash()
|
Method Summary | |
---|---|
static String |
asHexString(byte[] hash)
Get the string representation of the supplied binary hash. |
static SecureHash.HashingReader |
createHashingReader(SecureHash.Algorithm algorithm,
Reader reader,
Charset charset)
Create an Reader instance that wraps another reader and that computes the secure hash (using the algorithm with the supplied name) as the returned Reader is used. |
static SecureHash.HashingReader |
createHashingReader(String digestName,
Reader reader,
Charset charset)
Create an Reader instance that wraps another reader and that computes the secure hash (using the algorithm with the supplied name) as the returned Reader is used. |
static SecureHash.HashingInputStream |
createHashingStream(SecureHash.Algorithm algorithm,
InputStream inputStream)
Create an InputStream instance that wraps another stream and that computes the secure hash (using the algorithm with the supplied name) as the returned stream is used. |
static SecureHash.HashingInputStream |
createHashingStream(String digestName,
InputStream inputStream)
Create an InputStream instance that wraps another stream and that computes the secure hash (using the algorithm with the supplied name) as the returned stream is used. |
static byte[] |
getHash(SecureHash.Algorithm algorithm,
byte[] content)
Get the hash of the supplied content, using the supplied digest algorithm. |
static byte[] |
getHash(SecureHash.Algorithm algorithm,
File file)
Get the hash of the supplied content, using the supplied digest algorithm. |
static byte[] |
getHash(SecureHash.Algorithm algorithm,
InputStream stream)
Get the hash of the supplied content, using the supplied digest algorithm. |
static byte[] |
getHash(String digestName,
byte[] content)
Get the hash of the supplied content, using the digest identified by the supplied name. |
static byte[] |
getHash(String digestName,
File file)
Get the hash of the supplied content, using the digest identified by the supplied name. |
static byte[] |
getHash(String digestName,
InputStream stream)
Get the hash of the supplied content, using the digest identified by the supplied name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SecureHash()
Method Detail |
---|
public static byte[] getHash(SecureHash.Algorithm algorithm, byte[] content) throws NoSuchAlgorithmException
algorithm
- the hashing function algorithm that should be usedcontent
- the content to be hashed; may not be null
NoSuchAlgorithmException
- if the supplied algorithm could not be found
IllegalArgumentException
- if the algorithm is nullpublic static byte[] getHash(SecureHash.Algorithm algorithm, File file) throws NoSuchAlgorithmException, IOException
algorithm
- the hashing function algorithm that should be usedfile
- the file containing the content to be hashed; may not be null
NoSuchAlgorithmException
- if the supplied algorithm could not be found
IllegalArgumentException
- if the algorithm is null
IOException
- if there is an error reading the filepublic static byte[] getHash(SecureHash.Algorithm algorithm, InputStream stream) throws NoSuchAlgorithmException, IOException
algorithm
- the hashing function algorithm that should be usedstream
- the stream containing the content to be hashed; may not be null
NoSuchAlgorithmException
- if the supplied algorithm could not be found
IllegalArgumentException
- if the algorithm is null
IOException
- if there is an error reading the streampublic static byte[] getHash(String digestName, byte[] content) throws NoSuchAlgorithmException
digestName
- the name of the hashing function (or message digest
) that should be usedcontent
- the content to be hashed; may not be null
NoSuchAlgorithmException
- if the supplied algorithm could not be foundpublic static byte[] getHash(String digestName, File file) throws NoSuchAlgorithmException, IOException
digestName
- the name of the hashing function (or message digest
) that should be usedfile
- the file whose content is to be hashed; may not be null
NoSuchAlgorithmException
- if the supplied algorithm could not be found
IOException
- if there is an error reading the filepublic static byte[] getHash(String digestName, InputStream stream) throws NoSuchAlgorithmException, IOException
digestName
- the name of the hashing function (or message digest
) that should be usedstream
- the stream containing the content to be hashed; may not be null
NoSuchAlgorithmException
- if the supplied algorithm could not be found
IOException
- if there is an error reading the streampublic static SecureHash.HashingInputStream createHashingStream(SecureHash.Algorithm algorithm, InputStream inputStream) throws NoSuchAlgorithmException
algorithm
- the hashing function algorithm that should be usedinputStream
- the stream containing the content that is to be hashed
NoSuchAlgorithmException
public static SecureHash.HashingInputStream createHashingStream(String digestName, InputStream inputStream) throws NoSuchAlgorithmException
digestName
- the name of the hashing function (or message digest
) that should be usedinputStream
- the stream containing the content that is to be hashed
NoSuchAlgorithmException
public static SecureHash.HashingReader createHashingReader(SecureHash.Algorithm algorithm, Reader reader, Charset charset) throws NoSuchAlgorithmException
algorithm
- the hashing function algorithm that should be usedreader
- the reader containing the content that is to be hashedcharset
- the character set used within the supplied reader; may not be null
NoSuchAlgorithmException
public static SecureHash.HashingReader createHashingReader(String digestName, Reader reader, Charset charset) throws NoSuchAlgorithmException
digestName
- the name of the hashing function (or message digest
) that should be usedreader
- the reader containing the content that is to be hashedcharset
- the character set used within the supplied reader; may not be null
NoSuchAlgorithmException
public static String asHexString(byte[] hash)
hash
- the binary hash
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |