flexible hash algorithm