public class HashService extends Object
See also:
* HashAlgorithm
Modifier and Type | Field and Description |
---|---|
private static int |
BUFFER_SIZE |
private static org.slf4j.Logger |
logger |
private static String |
UTF_16_DESCRIPTION |
Constructor and Description |
---|
HashService() |
Modifier and Type | Method and Description |
---|---|
private static byte[] |
blake2Hash(HashAlgorithm algorithm,
byte[] value) |
private static byte[] |
blake2HashStreaming(HashAlgorithm algorithm,
InputStream value) |
static AllowableValue[] |
buildCharacterSetAllowableValues()
Returns an array of
AllowableValue elements for each Charset . |
static AllowableValue[] |
buildHashAlgorithmAllowableValues()
Returns an array of
AllowableValue elements for each HashAlgorithm . |
static List<Charset> |
getSupportedCharsets()
|
static String |
hashValue(HashAlgorithm algorithm,
String value)
Returns the hex-encoded hash of the specified value.
|
static String |
hashValue(HashAlgorithm algorithm,
String value,
Charset charset)
Returns the hex-encoded hash of the specified value.
|
static byte[] |
hashValueRaw(HashAlgorithm algorithm,
byte[] value)
Returns the raw
byte[] hash of the specified value. |
static byte[] |
hashValueRaw(HashAlgorithm algorithm,
String value)
Returns the raw
byte[] hash of the specified value. |
static byte[] |
hashValueRaw(HashAlgorithm algorithm,
String value,
Charset charset)
Returns the raw
byte[] hash of the specified value. |
static String |
hashValueStreaming(HashAlgorithm algorithm,
InputStream value)
Returns the hash of the specified value.
|
private static byte[] |
traditionalHash(HashAlgorithm algorithm,
byte[] value) |
private static byte[] |
traditionalHashStreaming(HashAlgorithm algorithm,
InputStream value) |
private static final org.slf4j.Logger logger
private static final int BUFFER_SIZE
private static final String UTF_16_DESCRIPTION
public static AllowableValue[] buildHashAlgorithmAllowableValues()
AllowableValue
elements for each HashAlgorithm
. The
complete description
is built from the digest length, safety warnings, etc. See
HashAlgorithm.buildAllowableValueDescription()
.AllowableValue[]
containing the valuespublic static AllowableValue[] buildCharacterSetAllowableValues()
AllowableValue
elements for each Charset
. Only the charsets in StandardCharsets
are returned to be consistent across JVM instances.AllowableValue[]
containing the valuespublic static List<Charset> getSupportedCharsets()
List
of supported Charset
s on this platform. This is not a complete
list, as only the charsets in StandardCharsets
are returned to be consistent across
JVM instances.public static String hashValueStreaming(HashAlgorithm algorithm, InputStream value) throws IOException
InputStream
to perform the operation in a streaming manner for large inputs.algorithm
- the hash algorithm to usevalue
- the value to hash (cannot be null
but can be an empty stream)IOException
public static String hashValue(HashAlgorithm algorithm, String value, Charset charset)
algorithm
- the hash algorithm to usevalue
- the value to hash (cannot be null
but can be an empty String)charset
- the charset to usepublic static String hashValue(HashAlgorithm algorithm, String value)
StandardCharsets.UTF_8
) is used.algorithm
- the hash algorithm to usevalue
- the value to hash (cannot be null
but can be an empty String)public static byte[] hashValueRaw(HashAlgorithm algorithm, String value, Charset charset)
byte[]
hash of the specified value.algorithm
- the hash algorithm to usevalue
- the value to hash (cannot be null
but can be an empty String)charset
- the charset to usepublic static byte[] hashValueRaw(HashAlgorithm algorithm, String value)
byte[]
hash of the specified value. The default charset (StandardCharsets.UTF_8
) is used.algorithm
- the hash algorithm to usevalue
- the value to hash (cannot be null
but can be an empty String)public static byte[] hashValueRaw(HashAlgorithm algorithm, byte[] value)
byte[]
hash of the specified value.algorithm
- the hash algorithm to usevalue
- the value to hashprivate static byte[] traditionalHash(HashAlgorithm algorithm, byte[] value)
private static byte[] traditionalHashStreaming(HashAlgorithm algorithm, InputStream value) throws IOException
IOException
private static byte[] blake2Hash(HashAlgorithm algorithm, byte[] value)
private static byte[] blake2HashStreaming(HashAlgorithm algorithm, InputStream value) throws IOException
IOException
Copyright © 2021 Apache NiFi Project. All rights reserved.