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 ) ; } }
Calculate the hash value of a given string .