/** * Returns the hex-encoded hash of the specified value. The default charset ({@code StandardCharsets.UTF_8}) is used. * * @param algorithm the hash algorithm to use * @param value the value to hash (cannot be {@code null} but can be an empty String) * @return the hash value in hex */ public static String hashValue(HashAlgorithm algorithm, String value) { return hashValue(algorithm, value, StandardCharsets.UTF_8); }
private String hashValue(HashAlgorithm algorithm, String value, Charset charset) { if (value == null) { getLogger().warn("Tried to calculate {} hash of null value; returning empty string", new Object[]{algorithm.getName()}); return ""; } return HashService.hashValue(algorithm, value, charset); }
/** * Returns the hex-encoded hash of the specified value. The default charset ({@code StandardCharsets.UTF_8}) is used. * * @param algorithm the hash algorithm to use * @param value the value to hash (cannot be {@code null} but can be an empty String) * @return the hash value in hex */ public static String hashValue(HashAlgorithm algorithm, String value) { return hashValue(algorithm, value, StandardCharsets.UTF_8); }
private String hashValue(HashAlgorithm algorithm, String value, Charset charset) { if (value == null) { getLogger().warn("Tried to calculate {} hash of null value; returning empty string", new Object[]{algorithm.getName()}); return ""; } return HashService.hashValue(algorithm, value, charset); }