'Get the hash of some data, using a particular hash algorithm, if
specified.
:param data: The data to be hashed.
:type data: bytes
:param hasher: The name of a hash implementation, supported by hashlib,
or ``None``. Examples of valid values are ``\'sha1\'``,
``\'sha224\'``, ``\'sha384\'``, \'``sha256\'``, ``\'md5\'`` and
``\'sha512\'``. If no hasher is specified, the ``hasher``
attribute of the :class:`InstalledDistribution` instance
is used. If the hasher is determined to be ``None``, MD5
is used as the hashing algorithm.
:returns: The hash of the data. If a hasher was explicitly specified,
the returned hash will be prefixed with the specified hasher
followed by \'=\'.
:rtype: str'

def get_hash(self, data, hasher=None):

    if (hasher is None):
        hasher = self.hasher
    if (hasher is None):
        hasher = hashlib.md5
        prefix = u''
    else:
        hasher = getattr(hashlib, hasher)
        prefix = (u'%s=' % self.hasher)
    digest = hasher(data).digest()
    digest = base64.urlsafe_b64encode(digest).rstrip('=').decode(u'ascii')
    return (u'%s%s' % (prefix, digest))
