public String hash(String key){
  try {
    MessageDigest md=MessageDigest.getInstance(algorithm);
    byte[] keyBytes=key.getBytes("UTF-8");
    md.update(keyBytes,0,keyBytes.length);
    byte[] binaryhash=md.digest();
    return Base64.encode(binaryhash);
  }
 catch (  Exception e) {
    LOG.warn("Failed to get hash encoding for key: {}",key,e);
    return key;
  }
}

public String hash ( String key ) { try { MessageDigest md = MessageDigest . getInstance ( algorithm ) ; byte [ ] keyBytes = key . getBytes ( "UTF-8" ) ; md . update ( keyBytes , 0 , keyBytes . length ) ; byte [ ] binaryhash = md . digest ( ) ; return Base64 . encode ( binaryhash ) ; } catch ( Exception e ) { LOG . warn ( "Failed to get hash encoding for key: {}" , key , e ) ; return key ; } }
get the hash encoding of a key string .
