Java Utililty Methods XML Hash

List of utility methods to do XML Hash

Description

The list of methods to do XML Hash are organized into topic(s).

Method

StringhashToString(byte[] hash)
hash To String
return javax.xml.bind.DatatypeConverter.printHexBinary(hash);
Stringsha1Hash(String s)
sha Hash
MessageDigest cript = MessageDigest.getInstance("SHA-1");
cript.reset();
cript.update(s.getBytes("UTF8"));
byte[] encodedBytes = cript.digest();
return DatatypeConverter.printBase64Binary(encodedBytes);
StringstrHash(String value, String method)
str Hash
try {
    MessageDigest messageDiges = MessageDigest.getInstance(method);
    messageDiges.update(value.getBytes());
    byte[] buffer = messageDiges.digest();
    return DatatypeConverter.printHexBinary(buffer);
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException("Internal Error: No such algorithm");
booleanvalidatePassword(String password, String correctHash)
Validates a password using a hash.
return validatePassword(password.toCharArray(), correctHash);