public class FilesystemBasedDigest extends Object
Some performance reports: (done using java -server option)
Modifier and Type | Class and Description |
---|---|
static class |
FilesystemBasedDigest.DigestAlgo
All Algo that Digest Class could handle
|
Modifier and Type | Field and Description |
---|---|
static Charset |
UTF8
Format used for Files
|
Constructor and Description |
---|
FilesystemBasedDigest(FilesystemBasedDigest.DigestAlgo algo)
Constructor of an independent Digest
|
Modifier and Type | Method and Description |
---|---|
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(io.netty.buffer.ByteBuf buffer,
FilesystemBasedDigest.DigestAlgo algo)
Get hash with given
ByteBuf (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(io.netty.buffer.ByteBuf buffer)
Get hash with given
ByteBuf (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)
Initialize the MD5 support
|
static boolean |
isUseFastMd5() |
static byte[] |
passwdCrypt(byte[] pwd)
Crypt a password
|
static String |
passwdCrypt(String pwd)
Crypt a password
|
static void |
setUseFastMd5(boolean useFastMd5) |
void |
Update(byte[] bytes,
int offset,
int length)
Update the digest with new bytes
|
void |
Update(io.netty.buffer.ByteBuf buffer)
Update the digest with new buffer
|
public static final Charset UTF8
public FilesystemBasedDigest(FilesystemBasedDigest.DigestAlgo algo) throws NoSuchAlgorithmException
algo
- NoSuchAlgorithmException
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 void Update(io.netty.buffer.ByteBuf buffer)
public byte[] Final()
public static boolean initializeMd5(boolean mustUseFastMd5)
mustUseFastMd5
- True will use FastMD5 support, False will
use JVM
native MD5public static boolean isUseFastMd5()
public static void setUseFastMd5(boolean useFastMd5)
useFastMd5
- the useFastMd5 to setpublic 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
- will be closed at the end of this callalgo
- IOException
public static byte[] getHash(io.netty.buffer.ByteBuf buffer, FilesystemBasedDigest.DigestAlgo algo) throws IOException
ByteBuf
(from Netty)buffer
- this buffer will not be changedalgo
- IOException
public static byte[] getHashMd5(io.netty.buffer.ByteBuf buffer)
ByteBuf
(from Netty)buffer
- ByteBuf to use to get the hash and this buffer will
not
be changedpublic static final String getHex(byte[] hash)
hash
- public static final byte[] getFromHex(String hex)
hex
- public static final String passwdCrypt(String pwd)
pwd
- to cryptIOException
public static final byte[] passwdCrypt(byte[] pwd)
pwd
- to cryptIOException
public static final boolean equalPasswd(String pwd, String cryptPwd)
pwd
- cryptPwd
- IOException
public static final boolean equalPasswd(byte[] pwd, byte[] cryptPwd)
pwd
- cryptPwd
- Copyright © 2009–2020 Waarp. All rights reserved.