def _digest(self, alg, password, salt=None):
        """
        Helper method to perform the password digest.

        :param alg: The hash algorithm to use.
        :type alg: str - 'sha512' | 'bcrypt'
        :param password: The password to digest.
        :type password: str
        :param salt: The salt to use. In the case of bcrypt,
                     when storing the password, pass None;
                     when testing the password, pass the hashed value.
        :type salt: None or str
        :returns: The hashed value as a string.
        """
        cur_config = config.getConfig()
        if alg == 'sha512':
            return hashlib.sha512((password + salt).encode('utf8')).hexdigest()
        elif alg == 'bcrypt':
            try:
                import bcrypt
            except ImportError:
                raise Exception(
                    'Bcrypt module is not installed. See girder.local.cfg.')

            password = password.encode('utf8')

            if salt is None:
                rounds = int(cur_config['auth']['bcrypt_rounds'])
                return bcrypt.hashpw(password, bcrypt.gensalt(rounds))
            else:
                if isinstance(salt, six.text_type):
                    salt = salt.encode('utf8')
                return bcrypt.hashpw(password, salt)
        else:
            raise Exception(alg % 'Unsupported hash algorithm: %s')
dataset/ETHPy150Open girder/girder/girder/models/password.py/Password._digest/swapped operands of `%`