Java XML Hash strHash(String value, String method)

Here you can find the source of strHash(String value, String method)

Description

str Hash

License

Open Source License

Declaration

public static String strHash(String value, String method) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.xml.bind.DatatypeConverter;

public class Main {
    public static String strHash(String value, String method) {
        try {// ww  w  . j a  v  a  2 s . c om
            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");
        }
    }
}

Related

  1. hashPass(String plaintext)
  2. hashPassword(char[] password, String salt, String hashAlgo)
  3. hashPassword(String password)
  4. hashToString(byte[] hash)
  5. sha1Hash(String s)
  6. validatePassword(String password, String correctHash)