|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgoldengate.common.digest.FilesystemBasedDigest
public class FilesystemBasedDigest

Class implementing digest like MD5, SHA1. MD5 is based on the Fast MD5
implementation, without C library support, but can be revert to JVM native
digest.
Some performance reports: (done using java -server option)
| Nested Class Summary | |
|---|---|
static class |
FilesystemBasedDigest.DigestAlgo
All Algo that Digest Class could handle |
| Field Summary | |
|---|---|
protected FilesystemBasedDigest.DigestAlgo |
algo
|
protected Checksum |
checksum
|
protected MessageDigest |
digest
|
static String |
fastMd5Path
If using Fast MD5, should we used the binary JNI library, empty meaning no. |
protected MD5 |
md5
|
static boolean |
useFastMd5
Should a file MD5 be computed using FastMD5 |
| Constructor Summary | |
|---|---|
FilesystemBasedDigest(FilesystemBasedDigest.DigestAlgo algo)
Constructor of an independent Digest |
|
| Method Summary | |
|---|---|
static boolean |
digestEquals(byte[] dig1,
byte[] dig2)
|
static boolean |
digestEquals(String dig1,
byte[] dig2)
|
static boolean |
equalPasswd(byte[] pwd,
byte[] cryptPwd)
|
static boolean |
equalPasswd(String pwd,
String cryptPwd)
|
byte[] |
Final()
|
static byte[] |
getFromHex(String hex)
Get the array of bytes representation of the hexadecimal String |
static byte[] |
getHash(org.jboss.netty.buffer.ChannelBuffer buffer,
FilesystemBasedDigest.DigestAlgo algo)
Get hash with given ChannelBuffer (from Netty) |
static byte[] |
getHash(File f,
boolean nio,
FilesystemBasedDigest.DigestAlgo algo)
Get the Digest for the file using the specified algorithm using access through NIO or not |
static byte[] |
getHash(InputStream stream,
FilesystemBasedDigest.DigestAlgo algo)
Get the Digest for the file using the specified algorithm using access through NIO or not |
static byte[] |
getHashMd5(org.jboss.netty.buffer.ChannelBuffer buffer)
Get hash with given ChannelBuffer (from Netty) |
static byte[] |
getHashMd5(File f)
get the byte array of the MD5 for the given FileInterface using standard access |
static byte[] |
getHashMd5Nio(File f)
get the byte array of the MD5 for the given FileInterface using Nio access |
static byte[] |
getHashSha1(File f)
get the byte array of the SHA-1 for the given FileInterface using standard access |
static byte[] |
getHashSha1Nio(File f)
get the byte array of the SHA-1 for the given FileInterface using Nio access |
static String |
getHex(byte[] hash)
Get the hexadecimal representation as a String of the array of bytes |
void |
initialize()
(Re)Initialize the digest |
void |
initialize(FilesystemBasedDigest.DigestAlgo algo)
(Re)Initialize the digest |
static boolean |
initializeMd5(boolean mustUseFastMd5,
String path)
Initialize the MD5 support |
static void |
main(String[] argv)
Test function |
static byte[] |
passwdCrypt(byte[] pwd)
Crypt a password |
static String |
passwdCrypt(String pwd)
Crypt a password |
void |
Update(byte[] bytes,
int offset,
int length)
Update the digest with new bytes |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected MD5 md5
protected Checksum checksum
protected MessageDigest digest
protected FilesystemBasedDigest.DigestAlgo algo
public static boolean useFastMd5
public static String fastMd5Path
| Constructor Detail |
|---|
public FilesystemBasedDigest(FilesystemBasedDigest.DigestAlgo algo)
throws NoSuchAlgorithmException
algo -
NoSuchAlgorithmException| Method Detail |
|---|
public void initialize()
throws NoSuchAlgorithmException
NoSuchAlgorithmException
public void initialize(FilesystemBasedDigest.DigestAlgo algo)
throws NoSuchAlgorithmException
algo -
NoSuchAlgorithmException
public void Update(byte[] bytes,
int offset,
int length)
bytes - offset - length - public byte[] Final()
public static boolean initializeMd5(boolean mustUseFastMd5,
String path)
mustUseFastMd5 - True will use FastMD5 support, False will use JVM native MD5path - If useFastMD5 is True, if path is not null, specify the C Library (optional),
else if null will use the Java implementation
public static final boolean digestEquals(byte[] dig1,
byte[] dig2)
dig1 - dig2 -
public static final boolean digestEquals(String dig1,
byte[] dig2)
dig1 - dig2 -
public static byte[] getHashMd5Nio(File f)
throws IOException
f -
IOException
public static byte[] getHashMd5(File f)
throws IOException
f -
IOException
public static byte[] getHashSha1Nio(File f)
throws IOException
f -
IOException
public static byte[] getHashSha1(File f)
throws IOException
f -
IOException
public static byte[] getHash(File f,
boolean nio,
FilesystemBasedDigest.DigestAlgo algo)
throws IOException
f - nio - algo -
IOException
public static byte[] getHash(InputStream stream,
FilesystemBasedDigest.DigestAlgo algo)
throws IOException
stream - algo -
IOException
public static byte[] getHash(org.jboss.netty.buffer.ChannelBuffer buffer,
FilesystemBasedDigest.DigestAlgo algo)
throws IOException
ChannelBuffer (from Netty)
buffer - this buffer will not be changedalgo -
IOExceptionpublic static byte[] getHashMd5(org.jboss.netty.buffer.ChannelBuffer buffer)
ChannelBuffer (from Netty)
buffer - ChannelBuffer to use to get the hash and
this buffer will not be changed
public static final String getHex(byte[] hash)
hash -
public static final byte[] getFromHex(String hex)
hex -
public static final String passwdCrypt(String pwd)
pwd - to crypt
IOExceptionpublic static final byte[] passwdCrypt(byte[] pwd)
pwd - to crypt
IOException
public static final boolean equalPasswd(String pwd,
String cryptPwd)
pwd - cryptPwd -
IOException
public static final boolean equalPasswd(byte[] pwd,
byte[] cryptPwd)
pwd - cryptPwd -
public static void main(String[] argv)
throws IOException
argv - with 2 arguments as filename to hash and full path to the
Native Library
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||