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 |
---|---|
protected static byte[] |
EMPTY |
static Charset |
UTF8
Format used for Files
|
static int |
ZERO_COPY_CHUNK_SIZE |
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() |
FilesystemBasedDigest.DigestAlgo |
getAlgo() |
byte[] |
getBytes(io.netty.buffer.ByteBuf buffer)
One should call getOffset since offset within array could not 0
|
static byte[] |
getFromHex(String hex)
Get the array of bytes representation of the hexadecimal String
|
static byte[] |
getHash(byte[] buffer,
FilesystemBasedDigest.DigestAlgo algo)
Get hash with given byte array
|
static byte[] |
getHash(byte[] buffer,
int length,
FilesystemBasedDigest.DigestAlgo algo)
Get hash with given byte array
|
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 String |
getHex(byte[] hash)
Get the hexadecimal representation as a String of the array of bytes
|
int |
getOffset(io.netty.buffer.ByteBuf buffer) |
void |
initialize()
(Re)Initialize the digest
|
void |
initialize(FilesystemBasedDigest.DigestAlgo algo)
(Re)Initialize the digest
|
static byte[] |
passwdCrypt(byte[] pwd)
Crypt a password
|
static String |
passwdCrypt(String pwd)
Crypt a password
|
void |
Update(byte[] buffer)
Update the digest with new buffer
|
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
protected static final byte[] EMPTY
public static final int ZERO_COPY_CHUNK_SIZE
public FilesystemBasedDigest(FilesystemBasedDigest.DigestAlgo algo) throws NoSuchAlgorithmException
algo
- NoSuchAlgorithmException
public final void initialize() throws NoSuchAlgorithmException
NoSuchAlgorithmException
public final void initialize(FilesystemBasedDigest.DigestAlgo algo) throws NoSuchAlgorithmException
algo
- NoSuchAlgorithmException
public final FilesystemBasedDigest.DigestAlgo getAlgo()
public final void Update(byte[] bytes, int offset, int length)
bytes
- offset
- length
- public final byte[] getBytes(io.netty.buffer.ByteBuf buffer)
buffer
- public final int getOffset(io.netty.buffer.ByteBuf buffer)
buffer
- public final void Update(io.netty.buffer.ByteBuf buffer)
public final void Update(byte[] buffer)
public final byte[] Final()
public static boolean digestEquals(byte[] dig1, byte[] dig2)
dig1
- dig2
- public static 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[] 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[] getHash(byte[] buffer, FilesystemBasedDigest.DigestAlgo algo) throws IOException
buffer
- this buffer will not be changedalgo
- IOException
public static byte[] getHash(byte[] buffer, int length, FilesystemBasedDigest.DigestAlgo algo) throws IOException
buffer
- this buffer will not be changedlength
- the real size of the bufferalgo
- 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 String getHex(byte[] hash)
hash
- public static byte[] getFromHex(String hex)
hex
- public static String passwdCrypt(String pwd)
pwd
- to cryptpublic static byte[] passwdCrypt(byte[] pwd)
pwd
- to cryptpublic static boolean equalPasswd(String pwd, String cryptPwd)
pwd
- cryptPwd
- public static boolean equalPasswd(byte[] pwd, byte[] cryptPwd)
pwd
- cryptPwd
- Copyright © 2009–2022 Waarp. All rights reserved.