String hash(TemplateClass tc) {
        try {
            //Object enhancer = engine.conf().byteCodeEnhancer();
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.reset();
            messageDigest.update((engine.version() + tc.getTemplateSource(true)).getBytes("utf-8"));
            byte[] digest = messageDigest.digest();
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < digest.length; ++i) {
                int value = digest[i];
                if (value < 0) {
                    value += 256;
                }
                builder.append(Integer.toHexString(value));
            }
            return builder.toString();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
String hash ( TemplateClass tc ) { try { MessageDigest messageDigest = MessageDigest . getInstance ( "MD5" ) ; messageDigest . reset ( ) ; messageDigest . update ( ( engine . version ( ) + tc . getTemplateSource ( true ) ) . getBytes ( "utf-8" ) ) ; byte [ ] digest = messageDigest . digest ( ) ; StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < digest . length ; ++ i ) { int value = digest [ i ] ; if ( value < 0 ) { value += 256 ; } builder . append ( Integer . toHexString ( value ) ) ; } return builder . toString ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Build a hash of the source code.
To efficiently track source code modifications.