public enum Hasher extends Enum<Hasher>
| Modifier and Type | Field and Description |
|---|---|
static Charset |
DEFAULT_ENCODING |
int |
digestLength |
| Modifier and Type | Method and Description |
|---|---|
static String |
getHex(byte[] raw) |
String |
hash(InputStream stream)
Hash message from InputStream
|
String |
hash(Path filePath)
Hash message from Path
|
String |
hash(Path filePath,
String prefix)
Hash message from Path and string prefix
|
String |
hash(String message) |
String |
hash(String message,
Charset charset)
Hash message String with algorithm and charset
|
static Optional<Hasher> |
parse(String algo)
Parse Hasher value from String
|
static String |
shorten(String s,
int l) |
String |
toString() |
static Hasher |
valueOf(int length) |
static Hasher |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Hasher[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Hasher SHA_1
public static final Hasher SHA_256
public static final Hasher SHA_384
public static final Hasher SHA_512
public static final Charset DEFAULT_ENCODING
public final int digestLength
public static Hasher[] values()
for (Hasher c : Hasher.values()) System.out.println(c);
public static Hasher valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static Hasher valueOf(int length)
public static String getHex(byte[] raw)
public String hash(String message, Charset charset)
message - the String to hashcharset - the charset to use for messagepublic String hash(Path filePath)
filePath - representing the message to hashpublic String hash(Path filePath, String prefix)
filePath - representing the message to hashpublic String hash(InputStream stream)
stream - the message to hashpublic static Optional<Hasher> parse(String algo)
algo - the algorithm name as a StringCopyright © 2020–2021 ICIJ. All rights reserved.