private String hash ( String dataId ) { try { MessageDigest digest = MessageDigest . getInstance ( hashAlgorithm ) ; digest . update ( dataId . getBytes ( "UTF-8" ) ) ; return new BigInteger ( 1 , digest . digest ( ) ) . toString ( 32 ) ; } catch ( NumberFormatException e ) { throw new RuntimeException ( "Could not generate the hash code of '" + dataId + "' with the algorithm '" + hashAlgorithm + "'" , e ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( "Could not generate the hash code of '" + dataId + "' with the algorithm '" + hashAlgorithm + "'" , e ) ; } catch ( NoSuchAlgorithmException e ) { throw new RuntimeException ( "Could not generate the hash code of '" + dataId + "' with the algorithm '" + hashAlgorithm + "'" , e ) ; } }
Gives the hash code of the given data id