def get_hash(self, data, hasher=None):
if hasher is None:<EOL><INDENT>hasher = self.hasher<EOL><DEDENT>if hasher is None:<EOL><INDENT>hasher = hashlib.md5<EOL>prefix = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>hasher = getattr(hashlib, hasher)<EOL>prefix = '<STR_LIT>' % self.hasher<EOL><DEDENT>digest = hasher(data).digest()<EOL>digest = base64.urlsafe_b64encode(digest).rstrip(b'<STR_LIT:=>').decode('<STR_LIT:ascii>')<EOL>return '<STR_LIT>' % (prefix, digest)<EOL>
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