@ Override public String hash ( String input , Hash hashType ) { Preconditions . checkNotNull ( input ) ; Preconditions . checkNotNull ( hashType ) ; try { MessageDigest m = MessageDigest . getInstance ( hashType . toString ( ) ) ; byte [ ] out = m . digest ( input . getBytes ( Charsets . UTF_8 ) ) ; return encodeBase64 ( out ) ; } catch ( NoSuchAlgorithmException e ) { throw new IllegalArgumentException ( e ) ; } }
Create a hash using specific hashing algorithm .