code: public static String hash(String algorithm, String str, String charsetName) {
  		try {
  			byte[] digest = MessageDigest
  				.getInstance(algorithm)
  				.digest(strToBytesWithCharset(str, charsetName));
  			return EncodingUtils.hex(digest);
  		} catch (NoSuchAlgorithmException e) {
  			throw new IllegalArgumentException("Unsupported algorithm: " + algorithm, e);
  		}
  	}
docs: Calculate the hash value of a given string.
  
  @param algorithm    message digest algorithm.
  @param str          string to hash.
  @param charsetName  charset of string.
  @return           hash value of string.