public static String generateVerHash(IQ packet, String algorithm) {
        final String s = generateS(packet);

        // Compute ver by hashing S using the algorithm as specified in
        // RFC 3174 (with binary output) and encoding the hash using Base64 as
        // specified in Section 4 of RFC 4648 (note: the Base64 output
        // MUST NOT include whitespace and MUST set padding bits to zero).
        final String hashed = generateHash(s, algorithm);
        final String result = encodeHash(hashed);
        Log.trace("Calculated Caps Hash '{}' from Caps string '{}' from stanza: {}", result, s, packet);
        return result;
    }
Generates a 'ver' hash attribute used in validation to help prevent
poisoning of entity capabilities information.

@see #isValid(IQ)

The value of the 'ver' attribute is generated according to the method
outlined in XEP-0115.

@param packet IQ reply to the entity cap request.
@param algorithm The hashing algorithm to use (e.g. SHA-1)
@return the generated 'ver' hash
xmppserver/src/main/java/org/jivesoftware/openfire/entitycaps/EntityCapabilitiesManager.java