List of utility methods to do XML Hash
String | hashToString(byte[] hash) hash To String return javax.xml.bind.DatatypeConverter.printHexBinary(hash);
|
String | sha1Hash(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); |
String | strHash(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"); |
boolean | validatePassword(String password, String correctHash) Validates a password using a hash. return validatePassword(password.toCharArray(), correctHash);
|